Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
3067 leency 1
struct f70{
2
	dword	func;
3
	dword	param1;
4
	dword	param2;
5
	dword	param3;
6
	dword	param4;
7
	char	rezerv;
8
	dword	name;
9
};
10
 
11
struct BDVK{
12
	dword	attr;
13
	byte	type_name;
14
	byte	rez1, rez2, rez3;
15
	dword	timecreate;
16
	dword	datecreate;
17
	dword	timelastaccess;
18
	dword	datelastaccess;
19
	dword	timelastedit;
20
	dword	datelastedit;
21
	dword	sizelo;
22
	dword	sizehi;
23
	char	name[518];
24
};
25
 
3440 leency 26
inline fastcall void SetCurDir( ECX)
27
{
28
	$mov eax,30
29
	$mov ebx,1
30
	$int 0x40
31
}
3067 leency 32
 
3440 leency 33
inline fastcall void GetCurDir( ECX, EDX)
34
{
35
	$mov eax,30
36
	$mov ebx,2
37
	$int 0x40
38
}
39
 
3067 leency 40
///////////////////////////
3440 leency 41
//   Параметры файла    //
42
///////////////////////////
43
f70 getinfo_file_70;
44
:dword GetFileInfo(dword file_path, bdvk_struct)
45
{
46
    getinfo_file_70.func = 5;
47
    getinfo_file_70.param1 =
48
    getinfo_file_70.param2 =
49
    getinfo_file_70.param3 = 0;
50
    getinfo_file_70.param4 = bdvk_struct;
51
    getinfo_file_70.rezerv = 0;
52
    getinfo_file_70.name = file_path;
53
    $mov eax,70
54
    $mov ebx,#getinfo_file_70.func
3444 leency 55
    $int 0x40
3440 leency 56
}
57
 
58
///////////////////////////
3067 leency 59
//   Запуск программы    //
60
///////////////////////////
61
f70 run_file_70;
3363 leency 62
signed int RunProgram(dword run_path, run_param)
3067 leency 63
{
64
    run_file_70.func = 7;
65
    run_file_70.param1 =
66
    run_file_70.param3 =
67
    run_file_70.param4 =
68
    run_file_70.rezerv = 0;
69
    run_file_70.param2 = run_param;
70
    run_file_70.name = run_path;
71
    $mov eax,70
72
    $mov ebx,#run_file_70.func
73
    $int 0x40
74
}
75
 
76
///////////////////////////
77
//    Создание папки     //
78
///////////////////////////
79
f70 create_dir_70;
80
:int CreateDir(dword new_folder_path)
81
{
82
	create_dir_70.func = 9;
83
	create_dir_70.param1 =
84
	create_dir_70.param2 =
85
	create_dir_70.param3 =
86
	create_dir_70.param4 =
87
	create_dir_70.rezerv = 0;
88
	create_dir_70.name = new_folder_path;
89
	$mov eax,70
90
	$mov ebx,#create_dir_70.func
91
	$int 0x40
92
}
93
 
94
////////////////////////////
95
//  Удаление файла/папки  //
96
////////////////////////////
97
f70 del_file_70;
98
:int DeleteFile(dword del_file_path)
99
{
100
	del_file_70.func = 8;
101
	del_file_70.param1 =
102
	del_file_70.param2 =
103
	del_file_70.param3 =
104
	del_file_70.param4 =
105
	del_file_70.rezerv = 0;
106
	del_file_70.name = del_file_path;
107
	$mov eax,70
108
	$mov ebx,#del_file_70.func
109
	$int 0x40
110
}
111
 
112
////////////////////////////
113
//     Прочитать файл     //
114
////////////////////////////
115
f70 read_file_70;
116
:int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path)
117
{
118
	read_file_70.func = 0;
119
	read_file_70.param1 = read_pos;
120
	read_file_70.param2 = 0;
121
	read_file_70.param3 = read_file_size;
122
	read_file_70.param4 = read_buffer;
123
	read_file_70.rezerv = 0;
124
	read_file_70.name = read_file_path;
125
	$mov eax,70
126
	$mov ebx,#read_file_70.func
127
	$int 0x40
128
}
129
 
130
////////////////////////////
131
//     Записать файл      //
132
////////////////////////////
133
f70 write_file_70;
134
:int WriteFile(dword write_file_size, write_buffer, write_file_path)
135
{
136
	write_file_70.func = 2;
137
	write_file_70.param1 = 0;
138
	write_file_70.param2 = 0;
139
	write_file_70.param3 = write_file_size;
140
	write_file_70.param4 = write_buffer;
141
	write_file_70.rezerv = 0;
142
	write_file_70.name = write_file_path;
143
	$mov eax,70
144
	$mov ebx,#write_file_70.func
145
	$int 0x40
146
}
147
 
148
///////////////////////////
149
//    Прочитать папку    //
150
///////////////////////////
151
f70 read_dir_70;
152
:int ReadDir(dword file_count, read_buffer, dir_path)
3363 leency 153
{
3067 leency 154
	read_dir_70.func = 1;
155
	read_dir_70.param1 =
156
	read_dir_70.param2 =
157
	read_dir_70.rezerv = 0;
158
	read_dir_70.param3 = file_count;
159
	read_dir_70.param4 = read_buffer;
160
	read_dir_70.name = dir_path;
161
	$mov eax,70
162
	$mov ebx,#read_dir_70.func
163
	$int 0x40
164
}
165
 
3440 leency 166
char isdir(dword fpath)
167
{
168
	BDVK fpath_atr;
169
	GetFileInfo(fpath, #fpath_atr);
3877 leency 170
	if (TestBit( fpath_atr.attr, 4)) return 1; else return 0;
3440 leency 171
}
3877 leency 172
 
3440 leency 173
:int GetFile(dword buf, filesize, read_path)
174
{
175
	BDVK ReadFile_atr;
176
	dword rBuf;
177
	if (! GetFileInfo(read_path, #ReadFile_atr))
178
	{
179
		rBuf = malloc(ReadFile_atr.sizelo);
180
		if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path))
181
		{
182
			ESDWORD[buf] = rBuf;
183
			ESDWORD[filesize] = ReadFile_atr.sizelo;
184
			return 1;
185
		}
186
	}
187
	free(rBuf);
188
	return 0;
189
}
3067 leency 190
 
3444 leency 191
enum
3363 leency 192
{
3444 leency 193
	DIRS_ALL,
194
	DIRS_NOROOT,
195
	DIRS_ONLYREAL
196
};
197
:int GetDir(dword dir_buf, file_count, path, doptions)
198
{
3363 leency 199
	dword buf, fcount, error;
200
	buf = malloc(32);
201
	error = ReadDir(0, buf, path);
202
	if (!error)
203
	{
204
		fcount = ESDWORD[buf+8];
205
		buf = realloc(buf, fcount+1*304+32);
206
		ReadDir(fcount, buf, path);
3440 leency 207
		//fcount=EBX;
3444 leency 208
 
209
		if (doptions == DIRS_ONLYREAL)
210
		{
211
			if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
212
			if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
213
		}
214
		if (doptions == DIRS_NOROOT)
215
		{
216
			if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
217
		}
218
 
3363 leency 219
		ESDWORD[dir_buf] = buf;
220
		ESDWORD[file_count] = fcount;
221
	}
3440 leency 222
	else
3067 leency 223
	{
3440 leency 224
		ESDWORD[file_count] = 0;
225
		ESDWORD[dir_buf] = free(buf);
3067 leency 226
	}
3440 leency 227
	return error;
3067 leency 228
}
229
 
3440 leency 230
:void notify(dword notify_param)
3067 leency 231
{
232
	RunProgram("@notify", notify_param);
3081 leency 233
}
3432 leency 234
 
235
:dword abspath(dword relative_path) //GetAbsolutePathFromRelative()
236
{
237
	char absolute_path[4096];
4137 leency 238
	if (ESBYTE[relative_path]=='/')
239
	{
240
		strcpy(#absolute_path, relative_path);
241
	}
242
	else
243
	{
244
		strcpy(#absolute_path, #program_path);
245
		absolute_path[strrchr(#absolute_path, '/')] = '\0';
246
		strcat(#absolute_path, relative_path);
247
	}
3432 leency 248
	return #absolute_path;
249
}