Subversion Repositories Kolibri OS

Rev

Rev 6857 | Rev 7787 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1665 Nasarus 1
 
2
{
3
4
 
5
unsigned	*n;
6
unsigned	num_of_file; // number of files in directory
7024 leency 7
unsigned	*t;
1665 Nasarus 8
unsigned	type_of_file; // check is this a file or a folder
7024 leency 9
int		i, result;
2617 Albom 10
1665 Nasarus 11
 
7024 leency 12
2617 Albom 13
 
7024 leency 14
 
1665 Nasarus 15
k70.p04 = 0;
16
//k70.p08 = 0;
6857 siemargl 17
k70.p12 = 2;  // just for test exist & read number of entries
18
k70.p16 =  (unsigned) malloc(32+k70.p12*560);
3245 Albom 19
k70.p20 = 0;
1665 Nasarus 20
21
 
7024 leency 22
 
23
	{
24
	single_column_mode = TRUE;
25
	dir += 3;
26
	}
27
28
 
1665 Nasarus 29
	k70.p21 = cur_dir;
30
else
31
	k70.p21 = dir;
32
2617 Albom 33
 
34
if ( !((result==0) || (result==6)) ) // check does the directory exists
7024 leency 35
	{
1665 Nasarus 36
	free( (void*) k70.p16);
3245 Albom 37
	return FALSE;
1665 Nasarus 38
	}
39
40
 
3245 Albom 41
num_of_file = *n;
7024 leency 42
1665 Nasarus 43
 
6857 siemargl 44
k70.p12 = num_of_file;
45
free( (void*) k70.p16);
46
k70.p16 =  (unsigned) malloc(32+k70.p12*560);
47
if ( !k70.p16 )
48
	return FALSE;
49
50
 
51
if ( !((result==0) || (result==6)) )
52
	{
53
	free( (void*) k70.p16);
54
	return FALSE;
55
	}
56
57
 
7024 leency 58
// otherwise show files in several columns
59
if (single_column_mode == TRUE)
60
{
61
_SINGLE_COLUMN_MODE:
62
	for (i = 0; i < num_of_file; i++)
63
	{
1665 Nasarus 64
	printf ("  %s", k70.p16+32+40+(264+40)*i);
65
	t =  (unsigned*) (k70.p16+32+(264+40)*i);
3245 Albom 66
	type_of_file = *t;
1665 Nasarus 67
	if ( (0x10 == (type_of_file&0x10)) || (8 == (type_of_file&8)) )
68
		printf ("/");
69
	printf ("\n\r");
70
	}
71
}
7024 leency 72
else
73
{
74
	int longest_name_len = 0;
75
	int console_window_width = 78; //need to get this value from console.obj if it's possible
76
	for (i = 0; i < num_of_file; i++)
77
		{
78
		int current_name_len;
79
		current_name_len = strlen( (char*)k70.p16+32+40+(264+40)*i);
80
		if (current_name_len > longest_name_len) longest_name_len = current_name_len;
81
		}
82
1665 Nasarus 83
 
7024 leency 84
	int columns_max = console_window_width / longest_name_len;
85
86
 
87
88
 
89
		{
90
		char cur_file[2048];
91
		strncpy(cur_file, (char*)k70.p16+32+40+(304)*i, sizeof(cur_file)-2);
92
93
 
94
		type_of_file = *t;
95
96
 
97
98
 
99
100
 
101
		}
102
	if ((i)%columns_max != 0) printf("\n\r");
103
}
104
105
 
3245 Albom 106
return TRUE;
1665 Nasarus 107
}
108