Subversion Repositories Kolibri OS

Rev

Rev 3440 | 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);
170
	if (TestBit(fpath_atr.attr, 4)==1) return 1; else return 0;
171
}
172
:int GetFile(dword buf, filesize, read_path)
173
{
174
	BDVK ReadFile_atr;
175
	dword rBuf;
176
	if (! GetFileInfo(read_path, #ReadFile_atr))
177
	{
178
		rBuf = malloc(ReadFile_atr.sizelo);
179
		if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path))
180
		{
181
			ESDWORD[buf] = rBuf;
182
			ESDWORD[filesize] = ReadFile_atr.sizelo;
183
			return 1;
184
		}
185
	}
186
	free(rBuf);
187
	return 0;
188
}
3067 leency 189
 
3444 leency 190
enum
3363 leency 191
{
3444 leency 192
	DIRS_ALL,
193
	DIRS_NOROOT,
194
	DIRS_ONLYREAL
195
};
196
:int GetDir(dword dir_buf, file_count, path, doptions)
197
{
3363 leency 198
	dword buf, fcount, error;
199
	buf = malloc(32);
200
	error = ReadDir(0, buf, path);
201
	if (!error)
202
	{
203
		fcount = ESDWORD[buf+8];
204
		buf = realloc(buf, fcount+1*304+32);
205
		ReadDir(fcount, buf, path);
3440 leency 206
		//fcount=EBX;
3444 leency 207
 
208
		if (doptions == DIRS_ONLYREAL)
209
		{
210
			if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
211
			if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
212
		}
213
		if (doptions == DIRS_NOROOT)
214
		{
215
			if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
216
		}
217
 
3363 leency 218
		ESDWORD[dir_buf] = buf;
219
		ESDWORD[file_count] = fcount;
220
	}
3440 leency 221
	else
3067 leency 222
	{
3440 leency 223
		ESDWORD[file_count] = 0;
224
		ESDWORD[dir_buf] = free(buf);
3067 leency 225
	}
3440 leency 226
	return error;
3067 leency 227
}
228
 
3440 leency 229
:void notify(dword notify_param)
3067 leency 230
{
231
	RunProgram("@notify", notify_param);
3081 leency 232
}
3432 leency 233
 
234
:dword abspath(dword relative_path) //GetAbsolutePathFromRelative()
235
{
236
	char absolute_path[4096];
3440 leency 237
	if (ESBYTE[relative_path]=='/') return relative_path;
3432 leency 238
	strcpy(#absolute_path, #program_path);
239
	absolute_path[strrchr(#absolute_path, '/')] = '\0';
240
	strcat(#absolute_path, relative_path);
241
	return #absolute_path;
242
}