cmm: rename file_system.h to fs.h, reimplement dir_exists() function

git-svn-id: svn://kolibrios.org@7219 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-04-03 13:57:56 +00:00
parent 1d22e52024
commit abbc6b0346
15 changed files with 44 additions and 40 deletions

View File

@ -14,7 +14,7 @@
//===================================================// //===================================================//
#include "../lib/kolibri.h" #include "../lib/kolibri.h"
#include "../lib/file_system.h" #include "../lib/fs.h"
#include "../lib/gui.h" #include "../lib/gui.h"
#include "../lib/list_box.h" #include "../lib/list_box.h"
#include "../lib/menu.h" #include "../lib/menu.h"

View File

@ -10,7 +10,7 @@
#include "../lib/clipboard.h" #include "../lib/clipboard.h"
#include "../lib/strings.h" #include "../lib/strings.h"
#include "../lib/mem.h" #include "../lib/mem.h"
#include "../lib/file_system.h" #include "../lib/fs.h"
#include "../lib/gui.h" #include "../lib/gui.h"
#include "../lib/list_box.h" #include "../lib/list_box.h"
#include "../lib/random.h" #include "../lib/random.h"

View File

@ -1,7 +1,7 @@
#define MEMSIZE 0x9000 #define MEMSIZE 0x9000
#include "..\lib\strings.h" #include "..\lib\strings.h"
#include "..\lib\mem.h" #include "..\lib\mem.h"
#include "..\lib\file_system.h" #include "..\lib\fs.h"
void main() void main()

View File

@ -8,7 +8,7 @@
#ifndef INCLUDE_FILESYSTEM_H #ifndef INCLUDE_FILESYSTEM_H
#include "../lib/file_system.h" #include "../lib/fs.h"
#endif #endif
//===================================================// //===================================================//

View File

@ -4,7 +4,7 @@
#print "[include <copyf.h>]\n" #print "[include <copyf.h>]\n"
#ifndef INCLUDE_FILESYSTEM_H #ifndef INCLUDE_FILESYSTEM_H
#include "../lib/file_system.h" #include "../lib/fs.h"
#endif #endif
:int copyf(dword from1, in1) :int copyf(dword from1, in1)

View File

@ -3,7 +3,7 @@
#print "[include <dll.h>]\n" #print "[include <dll.h>]\n"
#ifndef INCLUDE_FILESYSTEM_H #ifndef INCLUDE_FILESYSTEM_H
#include "../lib/file_system.h" #include "../lib/fs.h"
#endif #endif
#ifdef LANG_RUS #ifdef LANG_RUS

View File

@ -1,6 +1,6 @@
#ifndef INCLUDE_FILESYSTEM_H #ifndef INCLUDE_FILESYSTEM_H
#define INCLUDE_FILESYSTEM_H #define INCLUDE_FILESYSTEM_H
#print "[include <file_system.h>]\n" #print "[include <fs.h>]\n"
#ifndef INCLUDE_DATE_H #ifndef INCLUDE_DATE_H
#include "../lib/date.h" #include "../lib/date.h"
@ -33,11 +33,6 @@
///////////////////////////
// Параметры файла //
///////////////////////////
:f70 getinfo_file_70; :f70 getinfo_file_70;
:dword GetFileInfo(dword file_path, bdvk_struct) :dword GetFileInfo(dword file_path, bdvk_struct)
{ {
@ -53,9 +48,6 @@
$int 0x40 $int 0x40
} }
/////////////////////////////////////
// Изменение параметров файла //
/////////////////////////////////////
:f70 setinfo_file_70; :f70 setinfo_file_70;
:dword SetFileInfo(dword file_path, bdvk_struct) :dword SetFileInfo(dword file_path, bdvk_struct)
{ {
@ -71,9 +63,6 @@
$int 0x40 $int 0x40
} }
///////////////////////////
// Запуск программы //
///////////////////////////
:f70 run_file_70; :f70 run_file_70;
:signed int RunProgram(dword run_path, run_param) :signed int RunProgram(dword run_path, run_param)
{ {
@ -89,9 +78,6 @@
$int 0x40 $int 0x40
} }
///////////////////////////
// Создание папки //
///////////////////////////
:f70 create_dir_70; :f70 create_dir_70;
:int CreateDir(dword new_folder_path) :int CreateDir(dword new_folder_path)
{ {
@ -107,9 +93,6 @@
$int 0x40 $int 0x40
} }
////////////////////////////
// Удаление файла/папки //
////////////////////////////
:f70 del_file_70; :f70 del_file_70;
:int DeleteFile(dword del_file_path) :int DeleteFile(dword del_file_path)
{ {
@ -125,9 +108,6 @@
$int 0x40 $int 0x40
} }
////////////////////////////
// Прочитать файл //
////////////////////////////
:f70 read_file_70; :f70 read_file_70;
:int ReadFile(dword offset, data_size, buffer, file_path) :int ReadFile(dword offset, data_size, buffer, file_path)
{ {
@ -177,9 +157,6 @@
} }
///////////////////////////
// Прочитать папку //
///////////////////////////
:f70 read_dir_70; :f70 read_dir_70;
:int ReadDir(dword file_count, read_buffer, dir_path) :int ReadDir(dword file_count, read_buffer, dir_path)
{ {
@ -195,12 +172,29 @@
$int 0x40 $int 0x40
} }
:bool dir_exists(dword fpath)
{
char buf[32];
if (!ReadDir(0, #buf, fpath)) return true;
return false;
}
/*
// This implementation of dir_exists() is faster than
// previous but here virtual folders like
// '/' and '/tmp' are not recognised as FOLDERS
// by GetFileInfo() => BDVK.isfolder attribute :(
:bool dir_exists(dword fpath) :bool dir_exists(dword fpath)
{ {
BDVK fpath_atr; BDVK fpath_atr;
if (GetFileInfo(fpath, #fpath_atr) != 0) return false; if (GetFileInfo(fpath, #fpath_atr) != 0) return false;
return fpath_atr.isfolder; return fpath_atr.isfolder;
} }
*/
:bool file_exists(dword fpath) :bool file_exists(dword fpath)
{ {
BDVK ReadFile_atr; BDVK ReadFile_atr;
@ -306,6 +300,7 @@ enum
sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm); sprintf(#ConvertSize_size_prefix,"%d %s",bytes,#size_nm);
return #ConvertSize_size_prefix; return #ConvertSize_size_prefix;
} }
:dword ConvertSize64(dword bytes_lo, bytes_hi) :dword ConvertSize64(dword bytes_lo, bytes_hi)
{ {
if (bytes_hi > 0) { if (bytes_hi > 0) {
@ -315,15 +310,18 @@ enum
} }
else return ConvertSize(bytes_lo); else return ConvertSize(bytes_lo);
} }
:dword notify(dword notify_param) :dword notify(dword notify_param)
{ {
return RunProgram("/sys/@notify", notify_param); return RunProgram("/sys/@notify", notify_param);
} }
:void die(dword _last_msg) :void die(dword _last_msg)
{ {
notify(_last_msg); notify(_last_msg);
ExitProcess(); ExitProcess();
} }
:unsigned char size[25]=0; :unsigned char size[25]=0;
:dword ConvertSizeToKb(unsigned int bytes) :dword ConvertSizeToKb(unsigned int bytes)
{ {

View File

@ -57,13 +57,13 @@
:int active_button_id = 0; :int active_button_id = 0;
:int DrawStandartCaptButton(dword x, y, id, text) :int DrawStandartCaptButton(dword x, y, id, text)
{ {
int padding_v = 5; #define padding_v 5
int padding_h = 15; #define padding_h 15
int right_margin = 12; #define right_margin 12
#define h padding_v + padding_v + 16 //16 font height
int tx = x + padding_h; int tx = x + padding_h;
int ty = y + padding_v+1; int ty = y + padding_v+1;
int tw = strlen(text)*8; int tw = strlen(text)*8;
int h = padding_v + padding_v + 16; //16 font height
int w = tw + padding_h + padding_h; int w = tw + padding_h + padding_h;

View File

@ -7,7 +7,7 @@
#include "../lib/mem.h" #include "../lib/mem.h"
#include "../lib/dll.h" #include "../lib/dll.h"
#include "../lib/gui.h" #include "../lib/gui.h"
#include "../lib/file_system.h" #include "../lib/fs.h"
#include "../lib/list_box.h" #include "../lib/list_box.h"
#include "../lib/socket.h" #include "../lib/socket.h"
#include "../lib/draw_buf.h" #include "../lib/draw_buf.h"

View File

@ -7,7 +7,7 @@
#define MEMSIZE 0x23E80 #define MEMSIZE 0x23E80
#include "..\lib\strings.h" #include "..\lib\strings.h"
#include "..\lib\mem.h" #include "..\lib\mem.h"
#include "..\lib\file_system.h" #include "..\lib\fs.h"
#include "..\lib\gui.h" #include "..\lib\gui.h"
#include "..\lib\obj\libio.h" #include "..\lib\obj\libio.h"
#include "..\lib\obj\box_lib.h" #include "..\lib\obj\box_lib.h"

View File

@ -6,7 +6,7 @@
#include "..\lib\kolibri.h" #include "..\lib\kolibri.h"
#include "..\lib\strings.h" #include "..\lib\strings.h"
#include "..\lib\mem.h" #include "..\lib\mem.h"
#include "..\lib\file_system.h" #include "..\lib\fs.h"
#include "..\lib\dll.h" #include "..\lib\dll.h"
#include "..\lib\gui.h" #include "..\lib\gui.h"

View File

@ -9,7 +9,7 @@
char default_dir[] = "/rd/1"; char default_dir[] = "/rd/1";
od_filter filter2 = { 8, "MP3\0\0" }; od_filter filter2 = { 8, "MP3\0\0" };
#include "..\lib\file_system.h" #include "..\lib\fs.h"
#include "..\lib\list_box.h" #include "..\lib\list_box.h"
#include "..\lib\gui.h" #include "..\lib\gui.h"

View File

@ -6,7 +6,7 @@
// // // //
//===================================================// //===================================================//
#include "../lib/file_system.h" #include "../lib/fs.h"
#include "../lib/list_box.h" #include "../lib/list_box.h"
#include "../lib/gui.h" #include "../lib/gui.h"
#include "../lib/random.h" #include "../lib/random.h"

View File

@ -0,0 +1,6 @@
if tup.getconfig("NO_CMM") ~= "" then return end
if tup.getconfig("LANG") == "ru"
then C_LANG = "LANG_RUS"
else C_LANG = "LANG_ENG" -- this includes default case without config
end
tup.rule("taskbar2.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "taskbar2.com")

View File

@ -2,7 +2,7 @@
#include "..\lib\kolibri.h" #include "..\lib\kolibri.h"
#include "..\lib\mem.h" #include "..\lib\mem.h"
#include "..\lib\strings.h" #include "..\lib\strings.h"
#include "..\lib\file_system.h" #include "..\lib\fs.h"
#include "..\lib\dll.h" #include "..\lib\dll.h"
#include "..\lib\obj\libio.h" #include "..\lib\obj\libio.h"