2
// AggPas 2.4 RM3 demo framework file utility library
3
// Milan Marusinec alias Milano (c) 2006
17
api_file_ptr = ^api_file;
19
fileName : shortstring;
25
// FSOpenFork parameters
31
function cut_str(s : shortstring ) : shortstring;
32
function up_str (s : shortstring ) : shortstring;
33
function cmp_str(s : shortstring ) : shortstring;
35
function str_dir(s : shortstring ) : shortstring;
36
function dir_str(s : shortstring ) : shortstring;
38
function str_disk(fn : shortstring ) : shortstring;
39
function str_path(fn : shortstring ) : shortstring;
40
function str_name(fn : shortstring ) : shortstring;
41
function str_ext (fn : shortstring ) : shortstring;
43
function fold_name (p ,n ,x : shortstring ) : shortstring;
44
procedure spread_name(fn : shortstring; var p ,n ,x : shortstring );
46
function file_exists(fn : shortstring ) : boolean;
48
function api_open_file (var af : api_file; fname : shortstring ) : boolean;
49
function api_read_file (var af : api_file; buff : pointer; aloc : int; var read : int ) : boolean;
50
function api_close_file(var af : api_file ) : boolean;
52
function param_count : int;
53
function param_str(i : int ) : shortstring;
57
{ LOCAL VARIABLES & CONSTANTS }
62
SCAN_1 ,SCAN_2 ,SCAN_3 ,SCAN_4 ,SCAN_5 ,SCAN_6 ,SCAN_7 ,SCAN_8 ,SCAN_9 ,
63
SCAN_A ,SCAN_B ,SCAN_C ,SCAN_D ,SCAN_E ,SCAN_F ,SCAN_G ,SCAN_H ,SCAN_I ,
64
SCAN_J ,SCAN_K ,SCAN_L ,SCAN_M ,SCAN_N ,SCAN_O ,SCAN_P ,SCAN_Q ,SCAN_R ,
65
SCAN_S ,SCAN_T ,SCAN_U ,SCAN_V ,SCAN_W ,SCAN_X ,SCAN_Y ,SCAN_Z
72
ITEM_1 ,ITEM_2 ,ITEM_3 ,ITEM_4 ,ITEM_5 ,ITEM_6 ,ITEM_7 ,ITEM_8 ,ITEM_9 ,
73
ITEM_A ,ITEM_B ,ITEM_C ,ITEM_D ,ITEM_E ,ITEM_F ,ITEM_G ,ITEM_H ,ITEM_I ,
74
ITEM_J ,ITEM_K ,ITEM_L ,ITEM_M ,ITEM_N ,ITEM_O ,ITEM_P ,ITEM_Q ,ITEM_R ,
75
ITEM_S ,ITEM_T ,ITEM_U ,ITEM_V ,ITEM_W ,ITEM_X ,ITEM_Y ,ITEM_Z
82
pageEqHigh : shortstring =
83
#1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16 +
84
#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31#32 +
85
#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48 +
86
#49#50#51#52#53#54#55#56#57#58#59#60#61#62#63#64 +
87
#65#66#67#68#69#70#71#72#73#74#75#76#77#78#79#80 +
88
#81#82#83#84#85#86#87#88#89#90#91#92#93#94#95#96 +
89
#65#66#67#68#69#70#71#72#73#74#75#76#77#78#79#80 +
90
#81#82#83#84#85#86#87#88#89#90#123#124#125#126#127#128 +
91
#129#130#131#132#133#134#135#136#137#138#139#140#141#142#143#144 +
92
#145#146#147#148#149#150#151#152#153#154#155#156#157#158#159#160 +
93
#161#162#163#164#165#166#167#168#169#170#171#172#173#174#175#176 +
94
#177#178#179#180#181#182#183#184#185#186#187#188#189#190#191#192 +
95
#193#194#195#196#197#198#199#200#201#202#203#204#205#206#207#208 +
96
#209#210#211#212#213#214#215#216#217#218#219#220#221#222#223#224 +
97
#225#226#227#228#229#230#231#232#233#234#235#236#237#238#239#240 +
98
#241#242#243#244#245#246#247#248#249#250#251#252#253#254#255;
100
{ UNIT IMPLEMENTATION }
112
if length(s ) > 0 then
113
for fcb:=length(s ) downto 1 do
129
result:=s[fcb ] + result;
138
cmp_str:=up_str(cut_str(s ) );
148
if length(s ) > 0 then
149
for fcb:=1 to length(s ) do
150
if byte(s[fcb ] ) > 0 then
151
s[fcb ]:=pageEqHigh[byte(s[fcb ] ) ];
162
if length(s ) > 0 then
163
if s[length(s ) ] <> dir_slash then
175
if length(s ) > 0 then
176
if s[length(s ) ] = dir_slash then
194
if length(fn ) > 0 then
195
for fcb:=1 to length(fn ) do
250
'\' ,'/' ,':' ,'<' ,'>' ,'.' ,'"' ,'|' ,#0..#31 :
294
if length(fn ) > 0 then
295
for fcb:=1 to length(fn ) do
353
pth:=pth + str + fn[fcb ];
382
if length(fn ) > 0 then
383
for fcb:=1 to length(fn ) do
560
if length(fn ) > 0 then
561
for fcb:=1 to length(fn ) do
634
result:=cut_str(ext );
651
pth:=str_dir (str_path(p ) );
655
result:=dsk + pth + nme + ext;
660
procedure spread_name;
662
p:=str_disk(fn ) + str_dir(str_path(fn ) );
669
function file_exists;
690
function api_open_file;
694
fillchar(af ,sizeof(api_file ) ,0 );
701
AssignFile(af.df ,fname );
708
af.fSize:=filesize(af.df );
718
function api_read_file;
725
if aloc > af.fSize - af.fRead then
726
aloc:=af.fSize - af.fRead;
728
blockread(af.df ,buff^ ,aloc ,read );
732
inc(af.fRead ,read );
745
function api_close_file;
751
system.close(af.df );
762
function param_count;
771
result:=ParamStr(i );