2015-07-22 20:32:54 +02:00
|
|
|
|
#ifndef INCLUDE_FILESYSTEM_H
|
|
|
|
|
#define INCLUDE_FILESYSTEM_H
|
2015-08-04 17:48:36 +02:00
|
|
|
|
#print "[include <file_system.h>]\n"
|
2015-07-22 20:32:54 +02:00
|
|
|
|
|
2015-08-02 00:08:58 +02:00
|
|
|
|
#ifndef INCLUDE_DATE_H
|
|
|
|
|
#include "../lib/date.h"
|
2015-07-22 20:32:54 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2015-02-27 21:25:28 +01:00
|
|
|
|
:struct f70{
|
2012-11-26 16:26:15 +01:00
|
|
|
|
dword func;
|
|
|
|
|
dword param1;
|
|
|
|
|
dword param2;
|
|
|
|
|
dword param3;
|
|
|
|
|
dword param4;
|
|
|
|
|
char rezerv;
|
|
|
|
|
dword name;
|
|
|
|
|
};
|
|
|
|
|
|
2015-02-27 21:25:28 +01:00
|
|
|
|
:struct BDVK {
|
|
|
|
|
dword readonly:1, hidden:1, system:1, volume_label:1, isfolder:1, notarchived:1, :0;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
byte type_name;
|
2014-04-26 11:52:23 +02:00
|
|
|
|
byte rez1, rez2, selected;
|
2015-02-27 21:25:28 +01:00
|
|
|
|
dword timecreate;
|
|
|
|
|
date datecreate;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
dword timelastaccess;
|
2015-02-27 21:25:28 +01:00
|
|
|
|
date datelastaccess;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
dword timelastedit;
|
2015-02-27 21:25:28 +01:00
|
|
|
|
date datelastedit;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
dword sizelo;
|
|
|
|
|
dword sizehi;
|
|
|
|
|
char name[518];
|
|
|
|
|
};
|
|
|
|
|
|
2013-04-02 15:33:32 +02:00
|
|
|
|
|
2015-02-27 21:25:28 +01:00
|
|
|
|
|
|
|
|
|
|
2015-08-02 00:08:58 +02:00
|
|
|
|
|
|
|
|
|
///////////////////////////
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> //
|
2013-04-02 15:33:32 +02:00
|
|
|
|
///////////////////////////
|
2015-02-25 19:38:01 +01:00
|
|
|
|
:f70 getinfo_file_70;
|
2013-04-02 15:33:32 +02:00
|
|
|
|
:dword GetFileInfo(dword file_path, bdvk_struct)
|
|
|
|
|
{
|
|
|
|
|
getinfo_file_70.func = 5;
|
|
|
|
|
getinfo_file_70.param1 =
|
|
|
|
|
getinfo_file_70.param2 =
|
|
|
|
|
getinfo_file_70.param3 = 0;
|
|
|
|
|
getinfo_file_70.param4 = bdvk_struct;
|
|
|
|
|
getinfo_file_70.rezerv = 0;
|
|
|
|
|
getinfo_file_70.name = file_path;
|
|
|
|
|
$mov eax,70
|
|
|
|
|
$mov ebx,#getinfo_file_70.func
|
2013-04-04 19:07:38 +02:00
|
|
|
|
$int 0x40
|
2013-04-02 15:33:32 +02:00
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2015-08-02 00:08:58 +02:00
|
|
|
|
/////////////////////////////////////
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> //
|
|
|
|
|
/////////////////////////////////////
|
2015-05-10 03:12:52 +02:00
|
|
|
|
:f70 setinfo_file_70;
|
|
|
|
|
:dword SetFileInfo(dword file_path, bdvk_struct)
|
|
|
|
|
{
|
|
|
|
|
setinfo_file_70.func = 6;
|
|
|
|
|
setinfo_file_70.param1 =
|
|
|
|
|
setinfo_file_70.param2 =
|
|
|
|
|
setinfo_file_70.param3 = 0;
|
|
|
|
|
setinfo_file_70.param4 = bdvk_struct;
|
|
|
|
|
setinfo_file_70.rezerv = 0;
|
|
|
|
|
setinfo_file_70.name = file_path;
|
|
|
|
|
$mov eax,70
|
|
|
|
|
$mov ebx,#setinfo_file_70.func
|
|
|
|
|
$int 0x40
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-02 00:08:58 +02:00
|
|
|
|
///////////////////////////
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> //
|
2012-11-26 16:26:15 +01:00
|
|
|
|
///////////////////////////
|
2015-02-25 19:38:01 +01:00
|
|
|
|
:f70 run_file_70;
|
|
|
|
|
:signed int RunProgram(dword run_path, run_param)
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
|
|
|
|
run_file_70.func = 7;
|
|
|
|
|
run_file_70.param1 =
|
|
|
|
|
run_file_70.param3 =
|
|
|
|
|
run_file_70.param4 =
|
|
|
|
|
run_file_70.rezerv = 0;
|
|
|
|
|
run_file_70.param2 = run_param;
|
|
|
|
|
run_file_70.name = run_path;
|
|
|
|
|
$mov eax,70
|
|
|
|
|
$mov ebx,#run_file_70.func
|
|
|
|
|
$int 0x40
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-02 00:08:58 +02:00
|
|
|
|
///////////////////////////
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> //
|
2012-11-26 16:26:15 +01:00
|
|
|
|
///////////////////////////
|
2015-02-25 19:38:01 +01:00
|
|
|
|
:f70 create_dir_70;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
:int CreateDir(dword new_folder_path)
|
|
|
|
|
{
|
|
|
|
|
create_dir_70.func = 9;
|
|
|
|
|
create_dir_70.param1 =
|
|
|
|
|
create_dir_70.param2 =
|
|
|
|
|
create_dir_70.param3 =
|
|
|
|
|
create_dir_70.param4 =
|
|
|
|
|
create_dir_70.rezerv = 0;
|
|
|
|
|
create_dir_70.name = new_folder_path;
|
|
|
|
|
$mov eax,70
|
|
|
|
|
$mov ebx,#create_dir_70.func
|
|
|
|
|
$int 0x40
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-02 00:08:58 +02:00
|
|
|
|
////////////////////////////
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD> //
|
2012-11-26 16:26:15 +01:00
|
|
|
|
////////////////////////////
|
2015-02-25 19:38:01 +01:00
|
|
|
|
:f70 del_file_70;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
:int DeleteFile(dword del_file_path)
|
|
|
|
|
{
|
|
|
|
|
del_file_70.func = 8;
|
|
|
|
|
del_file_70.param1 =
|
|
|
|
|
del_file_70.param2 =
|
|
|
|
|
del_file_70.param3 =
|
|
|
|
|
del_file_70.param4 =
|
|
|
|
|
del_file_70.rezerv = 0;
|
|
|
|
|
del_file_70.name = del_file_path;
|
|
|
|
|
$mov eax,70
|
|
|
|
|
$mov ebx,#del_file_70.func
|
|
|
|
|
$int 0x40
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-02 00:08:58 +02:00
|
|
|
|
////////////////////////////
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> //
|
2012-11-26 16:26:15 +01:00
|
|
|
|
////////////////////////////
|
2015-02-25 19:38:01 +01:00
|
|
|
|
:f70 read_file_70;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
:int ReadFile(dword read_pos, read_file_size, read_buffer, read_file_path)
|
|
|
|
|
{
|
|
|
|
|
read_file_70.func = 0;
|
|
|
|
|
read_file_70.param1 = read_pos;
|
|
|
|
|
read_file_70.param2 = 0;
|
|
|
|
|
read_file_70.param3 = read_file_size;
|
|
|
|
|
read_file_70.param4 = read_buffer;
|
|
|
|
|
read_file_70.rezerv = 0;
|
|
|
|
|
read_file_70.name = read_file_path;
|
|
|
|
|
$mov eax,70
|
|
|
|
|
$mov ebx,#read_file_70.func
|
|
|
|
|
$int 0x40
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-02 00:08:58 +02:00
|
|
|
|
///////////////////////////
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> //
|
|
|
|
|
///////////////////////////
|
2015-02-25 19:38:01 +01:00
|
|
|
|
:f70 write_file_70;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
:int WriteFile(dword write_file_size, write_buffer, write_file_path)
|
|
|
|
|
{
|
|
|
|
|
write_file_70.func = 2;
|
|
|
|
|
write_file_70.param1 = 0;
|
|
|
|
|
write_file_70.param2 = 0;
|
|
|
|
|
write_file_70.param3 = write_file_size;
|
|
|
|
|
write_file_70.param4 = write_buffer;
|
|
|
|
|
write_file_70.rezerv = 0;
|
|
|
|
|
write_file_70.name = write_file_path;
|
|
|
|
|
$mov eax,70
|
|
|
|
|
$mov ebx,#write_file_70.func
|
|
|
|
|
$int 0x40
|
2015-03-21 00:40:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-02 00:08:58 +02:00
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
// WriteInFileThatAlredyExists //
|
|
|
|
|
////////////////////////////////////////
|
2015-03-21 00:40:49 +01:00
|
|
|
|
:f70 write_file_offset_70;
|
|
|
|
|
:int WriteFileWithOffset(dword write_data_size, write_buffer, write_file_path, offset)
|
|
|
|
|
{
|
|
|
|
|
write_file_offset_70.func = 3;
|
|
|
|
|
write_file_offset_70.param1 = offset;
|
|
|
|
|
write_file_offset_70.param2 = 0;
|
|
|
|
|
write_file_offset_70.param3 = write_data_size;
|
|
|
|
|
write_file_offset_70.param4 = write_buffer;
|
|
|
|
|
write_file_offset_70.rezerv = 0;
|
|
|
|
|
write_file_offset_70.name = write_file_path;
|
|
|
|
|
$mov eax,70
|
|
|
|
|
$mov ebx,#write_file_offset_70.func
|
|
|
|
|
$int 0x40
|
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2015-08-02 00:08:58 +02:00
|
|
|
|
///////////////////////////
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> //
|
2012-11-26 16:26:15 +01:00
|
|
|
|
///////////////////////////
|
2015-02-25 19:38:01 +01:00
|
|
|
|
:f70 read_dir_70;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
:int ReadDir(dword file_count, read_buffer, dir_path)
|
2013-03-11 19:16:24 +01:00
|
|
|
|
{
|
2012-11-26 16:26:15 +01:00
|
|
|
|
read_dir_70.func = 1;
|
|
|
|
|
read_dir_70.param1 =
|
|
|
|
|
read_dir_70.param2 =
|
|
|
|
|
read_dir_70.rezerv = 0;
|
|
|
|
|
read_dir_70.param3 = file_count;
|
|
|
|
|
read_dir_70.param4 = read_buffer;
|
|
|
|
|
read_dir_70.name = dir_path;
|
|
|
|
|
$mov eax,70
|
|
|
|
|
$mov ebx,#read_dir_70.func
|
|
|
|
|
$int 0x40
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-19 01:33:21 +01:00
|
|
|
|
:char dir_exists(dword fpath)
|
2013-04-02 15:33:32 +02:00
|
|
|
|
{
|
|
|
|
|
BDVK fpath_atr;
|
|
|
|
|
GetFileInfo(fpath, #fpath_atr);
|
2015-02-27 21:25:28 +01:00
|
|
|
|
return fpath_atr.isfolder;
|
2013-04-02 15:33:32 +02:00
|
|
|
|
}
|
2016-02-19 01:33:21 +01:00
|
|
|
|
:char file_exists(dword fpath)
|
|
|
|
|
{
|
|
|
|
|
BDVK ReadFile_atr;
|
|
|
|
|
if (! GetFileInfo(fpath, #ReadFile_atr)) return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-31 20:33:48 +02:00
|
|
|
|
|
2013-04-02 15:33:32 +02:00
|
|
|
|
:int GetFile(dword buf, filesize, read_path)
|
|
|
|
|
{
|
2016-02-19 01:33:21 +01:00
|
|
|
|
int return_val = 0;
|
2013-04-02 15:33:32 +02:00
|
|
|
|
BDVK ReadFile_atr;
|
|
|
|
|
dword rBuf;
|
|
|
|
|
if (! GetFileInfo(read_path, #ReadFile_atr))
|
|
|
|
|
{
|
|
|
|
|
rBuf = malloc(ReadFile_atr.sizelo);
|
|
|
|
|
if (! ReadFile(0, ReadFile_atr.sizelo, rBuf, read_path))
|
|
|
|
|
{
|
|
|
|
|
ESDWORD[buf] = rBuf;
|
|
|
|
|
ESDWORD[filesize] = ReadFile_atr.sizelo;
|
2016-02-19 01:33:21 +01:00
|
|
|
|
return_val = 1;
|
2013-04-02 15:33:32 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(rBuf);
|
2016-02-19 01:33:21 +01:00
|
|
|
|
return return_val;
|
2013-04-02 15:33:32 +02:00
|
|
|
|
}
|
2012-11-26 16:26:15 +01:00
|
|
|
|
|
2013-04-04 19:07:38 +02:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
DIRS_ALL,
|
|
|
|
|
DIRS_NOROOT,
|
|
|
|
|
DIRS_ONLYREAL
|
|
|
|
|
};
|
|
|
|
|
:int GetDir(dword dir_buf, file_count, path, doptions)
|
2013-03-11 19:16:24 +01:00
|
|
|
|
{
|
|
|
|
|
dword buf, fcount, error;
|
|
|
|
|
buf = malloc(32);
|
|
|
|
|
error = ReadDir(0, buf, path);
|
|
|
|
|
if (!error)
|
|
|
|
|
{
|
|
|
|
|
fcount = ESDWORD[buf+8];
|
|
|
|
|
buf = realloc(buf, fcount+1*304+32);
|
|
|
|
|
ReadDir(fcount, buf, path);
|
2013-04-02 15:33:32 +02:00
|
|
|
|
//fcount=EBX;
|
2013-04-04 19:07:38 +02:00
|
|
|
|
|
|
|
|
|
if (doptions == DIRS_ONLYREAL)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
|
|
|
|
|
if (!strcmp("..",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
|
|
|
|
|
}
|
|
|
|
|
if (doptions == DIRS_NOROOT)
|
|
|
|
|
{
|
|
|
|
|
if (!strcmp(".",buf+72)) {fcount--; memmov(buf,buf+304,fcount*304);}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-11 19:16:24 +01:00
|
|
|
|
ESDWORD[dir_buf] = buf;
|
|
|
|
|
ESDWORD[file_count] = fcount;
|
|
|
|
|
}
|
2013-04-02 15:33:32 +02:00
|
|
|
|
else
|
2012-11-26 16:26:15 +01:00
|
|
|
|
{
|
2013-04-02 15:33:32 +02:00
|
|
|
|
ESDWORD[file_count] = 0;
|
|
|
|
|
ESDWORD[dir_buf] = free(buf);
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
2013-04-02 15:33:32 +02:00
|
|
|
|
return error;
|
2012-11-26 16:26:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-30 01:52:50 +01:00
|
|
|
|
:dword abspath(dword relative_path) //GetAbsolutePathFromRelative()
|
|
|
|
|
{
|
|
|
|
|
char absolute_path[4096];
|
2013-10-30 02:12:01 +01:00
|
|
|
|
if (ESBYTE[relative_path]=='/')
|
|
|
|
|
{
|
|
|
|
|
strcpy(#absolute_path, relative_path);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strcpy(#absolute_path, #program_path);
|
|
|
|
|
absolute_path[strrchr(#absolute_path, '/')] = '\0';
|
|
|
|
|
strcat(#absolute_path, relative_path);
|
|
|
|
|
}
|
2013-03-30 01:52:50 +01:00
|
|
|
|
return #absolute_path;
|
|
|
|
|
}
|
2015-02-27 02:47:38 +01:00
|
|
|
|
|
2015-07-21 03:10:37 +02:00
|
|
|
|
:byte ConvertSize_size_prefix[8];
|
2015-07-16 03:44:30 +02:00
|
|
|
|
:dword ConvertSize(dword bytes)
|
2015-02-27 02:47:38 +01:00
|
|
|
|
{
|
2015-07-21 03:10:37 +02:00
|
|
|
|
byte size_nm[4];
|
2015-09-05 16:04:04 +02:00
|
|
|
|
if (bytes>=1073741824) strlcpy(#size_nm, "Gb",2);
|
|
|
|
|
else if (bytes>=1048576) strlcpy(#size_nm, "Mb",2);
|
|
|
|
|
else if (bytes>=1024) strlcpy(#size_nm, "Kb",2);
|
|
|
|
|
else strlcpy(#size_nm, "b ",2);
|
2015-02-27 02:47:38 +01:00
|
|
|
|
while (bytes>1023) bytes/=1024;
|
2015-07-21 03:10:37 +02:00
|
|
|
|
sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm);
|
|
|
|
|
return #ConvertSize_size_prefix;
|
2015-03-01 22:36:17 +01:00
|
|
|
|
}
|
2015-07-30 17:49:09 +02:00
|
|
|
|
:dword notify(dword notify_param)
|
|
|
|
|
{
|
2016-10-05 00:46:07 +02:00
|
|
|
|
return RunProgram("/sys/@notify", notify_param);
|
2015-07-30 17:49:09 +02:00
|
|
|
|
}
|
2016-11-10 18:48:36 +01:00
|
|
|
|
:void die(dword _last_msg)
|
|
|
|
|
{
|
|
|
|
|
notify(_last_msg);
|
|
|
|
|
ExitProcess();
|
|
|
|
|
}
|
2015-03-01 22:36:17 +01:00
|
|
|
|
:dword ConvertSizeToKb(unsigned int bytes)
|
|
|
|
|
{
|
|
|
|
|
unsigned char size[25]=0;
|
|
|
|
|
unsigned int kb;
|
|
|
|
|
dword kb_line;
|
|
|
|
|
|
2016-10-05 15:26:19 +02:00
|
|
|
|
if (bytes >= 1024)
|
|
|
|
|
{
|
|
|
|
|
kb_line = itoa(bytes / 1024);
|
|
|
|
|
strcpy(#size, kb_line);
|
|
|
|
|
strcat(#size, " Kb");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
kb_line = itoa(bytes);
|
|
|
|
|
strcpy(#size, kb_line);
|
|
|
|
|
strcat(#size, " b");
|
|
|
|
|
}
|
2015-03-01 22:36:17 +01:00
|
|
|
|
|
|
|
|
|
return #size;
|
2015-07-22 20:32:54 +02:00
|
|
|
|
}
|
|
|
|
|
#endif
|