-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilenames.asm
1793 lines (1256 loc) · 54.9 KB
/
filenames.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;// This file is part of the Analog Box open source project.
;// Copyright 1999-2011 Andy J Turner
;//
;// This program is free software: you can redistribute it and/or modify
;// it under the terms of the GNU General Public License as published by
;// the Free Software Foundation, either version 3 of the License, or
;// (at your option) any later version.
;//
;// This program is distributed in the hope that it will be useful,
;// but WITHOUT ANY WARRANTY; without even the implied warranty of
;// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;// GNU General Public License for more details.
;//
;// You should have received a copy of the GNU General Public License
;// along with this program. If not, see <http://www.gnu.org/licenses/>.
;//
;////////////////////////////////////////////////////////////////////////////
;//
;// Authors: AJT Andy J Turner
;//
;// History:
;//
;// 2.41 Mar 04, 2011 AJT
;// Initial port to GPLv3
;//
;// ABOX242 AJT -- detabified
;//
;//##////////////////////////////////////////////////////////////////////////
;//
;// filenames.asm data and routines to work with file names
;// fileopen/save dialog
;// name conversion routines
;// app title
;// circuit and group strings
;//
;// TOC
;//
;// filename_GetUnused
;//
;// filename_InitFromString
;// filename_ChangeDirectoryTo
;//
;// filename_Initialize
;// filename_Destroy
;// filename_BuildDefaultCircuitPath
;// filename_SyncAppTitle
;//
;// filename_ONF2Proc
;// filename_OFNHookProc
;// filename_GetFileName
;//
;// filename_QueryAndSave
;//
;// filename_PackMRU
;// filename_SyncMRU
OPTION CASEMAP:NONE
.586
.MODEL FLAT
.NOLIST
INCLUDE <abox.inc>
.LIST
.DATA
comment ~ /*
FILENAME
file names are wrapped in a FILENAME struct
it contains
full path
pointer to name
pointer to extension
length
there is then a pool of filenames
the app then uses pointers to the cache
use filename_GetUnused to obtain a non intialized FILENAME
use filename_InitFromString to initialize it
use filename_PutUnused to release the name
*/ comment ~
pool_Declare_internal filename ;//, FILENAME, 16
filename_circuit_path dd 0 ;// points at current circuit name
filename_app_path dd 0 ;// points at the app path
filename_plugin_path dd 0 ;// last registerde plugin
filename_data_path dd 0 ;// last file object we used
filename_reader_path dd 0 ;// last media file we opened
filename_writer_path dd 0 ;// last media file we opened
filename_csvreader_path dd 0 ;// last csv file we opened
filename_csvwriter_path dd 0 ;// last csv file we opened
filename_bitmap_path dd 0 ;// last bitmap we saved
filename_mru1_path dd 0
filename_mru2_path dd 0
filename_mru3_path dd 0
filename_mru4_path dd 0
filename_mru5_path dd 0 ;// external load
filename_paste_path dd 0 ;// aka mru6, don't move this
filename_get_path dd 0 ;// transfer area for getting filenames
szUntitled db 'Untitled_00',0 ;// default file name
ALIGN 4
.CODE
;////////////////////////////////////////////////////////////////////
;//
;//
;// filename utility functions
;//
ASSUME_AND_ALIGN
filename_GetUnused PROC
;// returns an unused entry in ebx
;// uses eax, edx, ecx and ebx
pool_GetUnused filename, ebx
xor eax, eax
mov [ebx].pName, eax
mov [ebx].pExt, eax
mov [ebx].dwLength, eax
ret
filename_GetUnused ENDP
ASSUME_AND_ALIGN
filename_InitFromString PROC STDCALL USES edi bFull:DWORD
;// FILENAME_SPACE_TERMINATED EQU 1 ;// unquoted spaces terminate the name
;// FILENAME_FULL_PATH EQU 2 ;// expand entry to a full path
;// this function transfers a space or zero terminated string to filename
;// then verifies that it is a full path name
;// removes quotes
;// sets pName
;// sets pExt
;// set dwLength
;//
;// returns:
;//
;// eax = 1 if all went well
;// eax = 0 for error
;// esi at one passed whatever terminated the string
ASSUME ebx:PTR FILENAME ;// FILENAME to be intialized (presereved)
;// ASSUME esi:PTR BYTE ;// location of string, iterated
;// stack
;// esi edi ret bFull
;// 0 4 8 12
mov edi, ebx ;// edi has to point at the destination
call parse_and_xfer
;// edx returns with flags
;// esi is at end of string
;// dl 1 if tilde was found indicates a dos 8.3 path name
;// dl 2 if colon was found indicates a drive letter
;// dl 4 if slash was found indicates a full path
;// dl 8 if dot was found indicates a file extension
mov eax, 1 ;// assume we passed
.IF (bFull & FILENAME_FULL_PATH) && ( (dl != 0Eh) || (dl & 1) )
;// ABOX233 - if the input string was surrounded by quotes
;// we have to remove them, or GetFullPath fails
;// so we want to point get path at [ebx]
;// and store to the stack
push esi ;// save the end of the origonal source string
sub esp, 280 ;// max path buffer on the stack
lea esi, [ebx].szPath ;// point at the new source
mov edx, esp
invoke GetFullPathNameA, esi, 280, edx, 0
mov edi, ebx ;// point edi at the destination
mov esi, esp ;// point esi at the source
call parse_and_xfer
add esp, 280
pop esi
and dl, NOT 1 ;// turn off the tilde bit
mov eax, 1 ;// assume we passed
.IF (dl != 0Eh)
dec eax ;// fail
.ENDIF
.ENDIF
;// double check that we passed, dwLength must be no zero
;// eax already has the assumed pass/fail flag
.IF [ebx].dwLength == 0
xor eax, eax
.ENDIF
;// that should do it
ret
ASSUME_AND_ALIGN
parse_and_xfer:
ASSUME ebx:PTR FILENAME
;// edi must point at destination
;// esi must point at source
;// xfers esi to edi
;// removes quotes
;// sets
;// dl 1 if tilde was found indicates a dos 8.3 path name
;// dl 2 if colon was found indicates a drive letter
;// dl 4 if slash was found indicates a full path
;// dl 8 if dot was found indicates a file extension
xor eax, eax
sub ecx, ecx
mov edx, eax
stosd ;// zero pName
stosd ;// zero pExt
stosd ;// zero dwLength
mov [ebx].pName, edi;// set the pName(make sure it points to something)
;// ABOX232
;// special test to check for network drives
;// see if name begins with a double slash
;// if yes, the state that we have a colon
.IF (WORD PTR [esi]) == '\\'
or dl, 2 ;// set the got colon flag
.ENDIF
;// ABOX232
top_of_loop:
lodsb
CMPJMP al, '"', je got_quote ;// got quote flag
CMPJMP al, '/', je got_slash
CMPJMP al, 5Ch, je got_backslash ;// got slash flag
CMPJMP al, '~', je got_tilde ;// got tilde flag
CMPJMP al, ' ', je got_space
CMPJMP al, ':', je got_colon ;// got colon flag
CMPJMP al, '.', je got_dot ;// got dot ??
CMPJMP al, ah, je done_with_string ;// nul terminated
store_character:
stosb
inc [ebx].dwLength
jmp top_of_loop
got_quote:
xor cl, -1 ;// flip the in quote flag
jnz top_of_loop ;// continue if setting
jmp done_with_string;// otherwise we're done
got_slash:
mov al, '\' ;// convert to back slash
got_backslash:
stosb ;// store character
inc [ebx].dwLength ;// bump the length
mov [ebx].pName, edi;// set the pName
or dl, 4 ;// set the got slash flag
jmp top_of_loop ;// continue on
got_tilde:
or dl, 1 ;// set the got tilde flag
jmp store_character
got_space:
test cl, cl ;// in quote ?
jnz store_character ;// continue if so
test bFull, FILENAME_SPACE_TERMINATED ;// supposed to stop at unquted spaces ?
jnz done_with_string;// were don if yes
jmp store_character ;// otherwise contiune on
got_colon:
or dl, 2 ;// set the got colon flag
jmp store_character
got_dot:
stosb ;// store the char
inc [ebx].dwLength ;// bump the length
mov [ebx].pExt, edi ;// save the extension pointer
or dl, 8 ;// set the got dot flag
jmp top_of_loop ;// continue on
done_with_string:
mov al, ah ;// ah = 0
stosb ;// terminate
retn
filename_InitFromString ENDP
ASSUME_AND_ALIGN
filename_CopyNewDirectory PROC STDCALL uses esi edi ebx pName:DWORD, pDir:DWORD
;// returns a new FILENAME with pName changed to the directory stated by pDir
;// get an unused FILENAME
invoke filename_GetUnused
ASSUME ebx:PTR FILENAME
ASSUME edx:PTR FILENAME ;// used below
DEBUG_IF <!!pDir> ;// bad parameter
DEBUG_IF <!!pName> ;// bad parameter
;// copy directory
mov edx, pDir ;// get the directory
mov ecx, [edx].pName ;// point at name portion
DEBUG_IF <!!ecx> ;// bad filename
sub ecx, edx ;// bytes from start to name
sub ecx, FILENAME.szPath;// remove header bytes
lea esi, [edx].szPath ;// point at source string
mov edi, ebx ;// point at dest string
xor eax, eax ;// clear for zeroing
stosd ;// clear pName
stosd ;// clear pExt
stosd ;// clear length
mov [ebx].dwLength, ecx ;// start of dwLength
rep movsb ;// copy up to the directy
mov [ebx].pName, edi ;// store the name
;// copy the name
mov edx, pName
mov esi, [edx].pName
DEBUG_IF <!!esi> ;// bad name
S1: lodsb ;// get the char
cmp al, '.' ;// check for a dot
stosb ;// store the char
jne S2
mov [ebx].pExt, edi ;// set the extension
S2: test al, al ;// check for done
jz S3
inc [ebx].dwLength ;// bump the length
jmp S1
S3: ;// done with string
;// that should do
mov eax, ebx
ret
filename_CopyNewDirectory ENDP
;//
;// filename utility functions
;//
;//
;////////////////////////////////////////////////////////////////////
;////////////////////////////////////////////////////////////////////
;//
;//
;// filename public interface
;//
ASSUME_AND_ALIGN
filename_Initialize PROC
;// task: define filename_app_path
;// define filename_get_path as the commmand line arg
;//
;// returns ebx as the command line (or zero for none)
;// rely on filename_get_path to load the circuit
;// get the command line
invoke GetCommandLineA
mov esi, eax
ASSUME esi:PTR BYTE
;//ECHO TESTING ERASEME
;//invoke MessageBoxA, 0, esi, 0, IDOK
;// get an unused filename
invoke filename_GetUnused
ASSUME ebx:PTR FILENAME
mov filename_app_path, ebx ;// store it now
invoke filename_InitFromString, FILENAME_SPACE_TERMINATED OR FILENAME_FULL_PATH
DEBUG_IF <!!eax> ;// couldn't parse the app name ?!! this is bad
;// now we check for a command line
;// esi returns at one passed the character that terminated the previous string
;// check if a zero terminated it
cmp [esi-1], 0
je got_no_command_name
.REPEAT
lodsb
cmp al, 0
je got_no_command_name
cmp al, ' '
.UNTIL !ZERO?
dec esi
;// esi is at the beginning of a new string
;// we may have an arg ???
;// must have a command line
invoke filename_GetUnused ;// locate unused slot
invoke filename_InitFromString, FILENAME_SPACE_TERMINATED OR FILENAME_FULL_PATH
test eax, eax ;// see if we succeeded
jnz got_good_command_name
got_bad_command_name:
filename_PutUnused ebx ;// release this
got_no_command_name:
xor ebx, ebx
got_good_command_name:
mov filename_get_path, ebx ;// store the name
ret
filename_Initialize ENDP
ASSUME_AND_ALIGN
filename_Destroy PROC
pool_Destroy filename
ret
filename_Destroy ENDP
ASSUME_AND_ALIGN
filename_BuildDefaultCircuitPath PROC
;// action directory --> unused FILE_NAME --> filename_circuit_path
;// --> bIsUntitled
;// uses esi edi ebx
;// return the new FILE_NAME in ebx
;// this will be the new circuit_path
;// the old one is released if there is one
;// Untitled_00.ABox2
;// use directory of the last loaded path
;// if there is none, use the path of the executable
;// get a directory to work with
;// return the filename in ebx to use as a directory
ASSUME ebx:PTR FILENAME
xor ebx, ebx
or ebx, filename_circuit_path ;// is there already a circuit path ?
jz S1
S0: ;// this is hit from COMMAND_NEW
mov ebx, filename_circuit_path ;// useit
jmp S4
S1: ;// this is hit at app start
or ebx, filename_mru1_path ;// try the mru list
jnz S3
S2: ;// this is hit at the very first install
mov ebx, filename_app_path ;// build from filename_app_path
S3: ;// ebx points at the filename of the directory to use
lea esi, [ebx].szPath ;// point at the path
invoke filename_GetUnused ;// locate a new record
invoke filename_InitFromString, FILENAME_FULL_PATH ;// initialize from the path
mov filename_circuit_path, ebx ;// store as new circuit path
S4: ;// now ebx points at the FILENAME to base the new name on
;// build the default untitled name
mov edi, [ebx].pName ;// point at the name for next section
lea esi, szUntitled
mov ecx, (SIZEOF szUntitled)
rep movsb
mov [ebx].pExt, edi ;// store the exension (one passed dot)
dec edi ;// because we copied the terminator
mov eax, 'oBA.' ;// load first bytes of extension
stosd
mov eax, '2x' ;// load next bytes of extension
stosd
;// determine the new length of the name
lea edi, [ebx].szPath
xor eax, eax
STRLEN edi
mov [ebx].dwLength, eax
;// now we iterate until we dont find the file
lea edi, [ebx].szPath ;// point edi at full path
mov esi, [ebx].pName ;// point esi at Untitled_XX
ASSUME esi:PTR BYTE
sub esp, SIZEOF WIN32_FIND_DATA
top_of_verify: ;// iterate until we get invalid handle
invoke FindFirstFileA, edi, esp
inc eax ;// INVALID_HANDLE_VALUE = -1
jz verify_done
dec eax ;// this file exists
invoke FindClose, eax ;// close the find handle
inc [esi+10] ;// increase the lower digit
cmp [esi+10], ':' ;// check for wrap
jne top_of_verify ;// loop if no wrap
mov [esi+10], '0' ;// reset to zero
inc [esi+9] ;// increase the higher digit
cmp [esi+9], ':' ;// check for wrap
jne top_of_verify ;// loop if no wrap
mov [esi+9], 'A' ;// set to A (lot's of file)
jmp top_of_verify ;// jmp to top
;// max names 100 + 26 * 10 = 360
verify_done:
add esp, SIZEOF WIN32_FIND_DATA
;// set the is untitled flag
or mainmenu_mode, MAINMENU_UNTITLED
;// and we are done !
ret
filename_BuildDefaultCircuitPath ENDP
ASSUME_AND_ALIGN
filename_SyncAppTitle PROC uses esi edi ebx
;// task: format and set the app title
;// app_title "jambot_31 ABox 2.0 "
xor ebx, ebx
or ebx, filename_circuit_path
;// make sure we have a deafult name
jnz @F
invoke filename_BuildDefaultCircuitPath
@@:
ASSUME ebx:PTR FILENAME
;// get pointer to the app title
;// the append circuit name and app string
sub esp, 280
mov edi, esp
mov esi, [ebx].pName
xor eax, eax ;// clear for byte copy
push edi ;// store the new app title
;// store the dirty indicater
xor eax, eax
.IF unredo_we_are_dirty
mov ax, ' *'
stosw
xor eax, eax
.ENDIF
;// store the circuit name
@@:
lodsb ;// string copy the name
cmp al, '.' ;// don't store the dot
jz @F
test al, al ;// just incase things are really screwed up
jz @F
stosb
jmp @B
@@:
;// store the app title
mov eax, 'oBA '
stosd
mov al,'x'
stosb
mov eax, ABOX_VERSION_STRING_REVERSE
stosd
;// ABOX242 AJT -- we'll get a little sophisticated for the various versions
IFDEF ALPHABUILD
IFDEF DEBUGBUILD
;//' DEBUG ALPHA'
mov eax, 'BED '
stosd
mov eax, 'A GU'
stosd
mov eax, 'AHPL'
stosd
ELSE
;//' RELEASE ALPHA'
mov eax, 'LER '
stosd
mov eax, 'ESAE'
stosd
mov eax, 'PLA '
stosd
mov eax, 'AH'
stosw
ENDIF
ELSEIFDEF DEBUGBUILD
;//' DEBUG BETA'
mov eax, 'BED '
stosd
mov eax, 'B GU'
stosd
mov eax, 'ATE'
stosd
ENDIF
;// then terminate it
xor eax, eax
stosd
;// set the window title
push hMainWnd
call SetWindowTextA
add esp, 280
;// shut the flag off
and app_bFlags, NOT APP_SYNC_TITLE
ret
filename_SyncAppTitle ENDP
;//
;//
;// filename public interface
;//
;////////////////////////////////////////////////////////////////////
;///////////////////////////////////////////////////////////////////////////////////
;///////////////////////////////////////////////////////////////////////////////////
;///////////////////////////////////////////////////////////////////////////////////
;///////////////////////////////////////////////////////////////////////////////////
;///
;///
;///
;/// G E T F I L E N A M E
;///
;///
.DATA
ofnKludgeProc dd 0 ;//
getfilename_mode dd 0 ;//
;//
;// parameter table for filename_GetFilename
;//
;// algorithm
;//
;// if initializer is given
;// use that for both init directory and init name
;// else
;// use filename_circuit_path or filename_app_path
;// if defname is given
;// append that to initializer
;// else
;// append defext to circuit name
;// GETFILENAME_OPEN equ 0 ;// retreives a new file to load
;// GETFILENAME_SAVEAS equ 1 ;// retrieves the save name
;// GETFILENAME_PASTEFROM equ 2 ;// retrieves a file to paste
;// GETFILENAME_SAVEBMP equ 3 ;// save as a bitmap
;// GETFILENAME_PLUGIN equ 4 ;// find a plugin
;// GETFILENAME_DATA equ 5 ;// retrieves a name for an osc_File object
;// GETFILENAME_READER equ 6 ;// media reader
;// GETFILENAME_WRITER equ 7 ;// media writer
;// GETFILENAME_CSVWRITER equ 8 ;// csv writer
;// GETFILENAME_CAVREADER equ 9 ;// csv reader
GETFILENAME_TABLE STRUCT
opfn_flags dd 0 ;// flags for open filename
psz_title dd 0 ;// title string for the dialog
psz_filter dd 0 ;// pointer to the filter strinng
psz_defext dd 0 ;// default extention for the dialog
psz_defname dd 0 ;// pointer to initial name if a default initilaizer is used
psz_button dd 0 ;// desired button text
initializer dd 0 ;// pointer to pointer to filename used to initializethe dialog
dwFlags dd 0 ;// things we want to do
GETFILENAME_TABLE ENDS
GETFILENAME_FORCE_DEFNAME EQU 00000001h ;// force the use of default name from table
GETFILENAME_USE_SUBHOOK EQU 00000002h ;// use the sub hook
;//
;// string resources for filename_GetFilename
;//
;// format
;//
;// sz_ACTION_ filter displayed in the file type box
;// defname name to use as initializer is one is not specified
;// defext forced extension
;//
;// strings may be (and are) overlapped
;// open save paste
sz_paste_filter LABEL BYTE
sz_open_filter db 'ABox files (*.abox2;*.abox)',0,'*.ABox2;*.ABox',0,0
sz_paste_title db 'Paste from File',0
sz_paste_button db 'Paste',0
sz_saveas_filter db 'ABox2 files (*.abox2)',0 ;// single terminator
sz_paste_defname LABEL BYTE
sz_open_defname db '*.' ;// no terminator
sz_saveas_defext LABEL BYTE
sz_paste_defext LABEL BYTE
sz_open_defext db 'ABox2',0,0 ;// double terminator
GETFILENAME_OPEN_FLAGS EQU OFN_FILEMUSTEXIST OR OFN_PATHMUSTEXIST OR OFN_HIDEREADONLY OR OFN_LONGNAMES OR OFN_EXPLORER
GETNAME_FLAGS_OPEN EQU 0
sz_open_title EQU 0
sz_open_button EQU 0
getfilename_path_open TEXTEQU <filename_circuit_path>
GETFILENAME_SAVEAS_FLAGS EQU OFN_OVERWRITEPROMPT OR OFN_HIDEREADONLY OR OFN_LONGNAMES OR OFN_EXPLORER OR OFN_ENABLEHOOK
GETNAME_FLAGS_SAVEAS EQU GETFILENAME_USE_SUBHOOK
sz_saveas_title EQU 0
sz_saveas_defname EQU 0 ;// builds circuit name + .abox2
sz_saveas_button EQU 0
getfilename_path_saveas TEXTEQU <filename_circuit_path>
GETFILENAME_PASTE_FLAGS EQU OFN_FILEMUSTEXIST OR OFN_PATHMUSTEXIST OR OFN_HIDEREADONLY OR OFN_LONGNAMES OR OFN_EXPLORER OR OFN_ENABLEHOOK
GETNAME_FLAGS_PASTE EQU 0
getfilename_path_paste TEXTEQU <filename_paste_path>
;// bitmap
GETFILENAME_BITMAP_FLAGS EQU OFN_OVERWRITEPROMPT OR OFN_HIDEREADONLY OR OFN_LONGNAMES OR OFN_EXPLORER
sz_bitmap_title db 'Save As a Bitmap',0
sz_bitmap_filter db 'Bitmap files (*.bmp)',0,'*.' ;// no terminator
sz_bitmap_defext db 'bmp',0,0 ;// double terminator
sz_bitmap_defname EQU 0 ;// builds circuit name + .bmp
sz_bitmap_button EQU 0
getfilename_path_bitmap TEXTEQU <filename_bitmap_path>
GETNAME_FLAGS_BITMAP EQU 0
;// plugin
GETFILENAME_PLUGIN_FLAGS EQU OFN_HIDEREADONLY OR OFN_FILEMUSTEXIST OR OFN_PATHMUSTEXIST OR OFN_LONGNAMES OR OFN_EXPLORER OR OFN_ENABLEHOOK OR OFN_ALLOWMULTISELECT
sz_plugin_title db 'Register VST plugins', 0
sz_plugin_filter db 'VST Plugin Files (*.dll)',0 ;// single terminator
sz_plugin_defname db '*.' ;// no terminator
sz_plugin_defext db 'dll',0,0 ;// double terminator
sz_plugin_button db 'Register',0
getfilename_path_plugin TEXTEQU <filename_plugin_path>
GETNAME_FLAGS_PLUGIN EQU GETFILENAME_FORCE_DEFNAME
;// data reader writer
;// data file
GETFILENAME_DATA_FLAGS EQU OFN_HIDEREADONLY OR OFN_LONGNAMES OR OFN_EXPLORER OR OFN_ENABLEHOOK
sz_data_title db 'Open or Create a .DAT File',0
sz_data_filter db 'ABox Data files (*.dat)',0 ;// single terminator
sz_data_defname db '*.' ;// no terminator
sz_data_defext db 'dat',0,0 ;// double terminator
sz_data_button EQU 0
getfilename_path_data TEXTEQU <filename_data_path>
GETNAME_FLAGS_DATA EQU 0
;// media reader
GETFILENAME_READER_FLAGS EQU OFN_HIDEREADONLY OR OFN_LONGNAMES OR OFN_FILEMUSTEXIST OR OFN_PATHMUSTEXIST OR OFN_EXPLORER OR OFN_ENABLEHOOK
sz_reader_title db 'Open Media File',0
sz_reader_filter db 'Media Files (*.*)',0 ;// single terminator
;//"Video files (*.mpg; *.mpeg; *.avi; *.mov; *.qt)\0*.mpg; *.mpeg; *.avi; *.mov; *.qt\0\0";
sz_reader_defname db '*.*',0 ;// single terminator
sz_reader_defext db 0 ;// double terminator
sz_reader_button EQU 0
getfilename_path_reader TEXTEQU <filename_reader_path>
GETNAME_FLAGS_READER EQU 0
;// wave writer
GETFILENAME_WRITER_FLAGS EQU OFN_HIDEREADONLY OR OFN_LONGNAMES OR OFN_PATHMUSTEXIST OR OFN_EXPLORER OR OFN_ENABLEHOOK
sz_writer_title db 'Open or Create a .WAV file',0
sz_writer_filter db 'Wave Files (*.wav)',0,'*.' ;// no terminator
sz_writer_defext db 'wav',0,0
sz_writer_defname EQU 0 ;// builds circuit name + .wav
sz_writer_button EQU 0
getfilename_path_writer TEXTEQU <filename_writer_path>
GETNAME_FLAGS_WRITER EQU 0
;// csv reader
GETFILENAME_CSVREADER_FLAGS EQU OFN_HIDEREADONLY OR OFN_LONGNAMES OR OFN_FILEMUSTEXIST OR OFN_PATHMUSTEXIST OR OFN_EXPLORER OR OFN_ENABLEHOOK
sz_csvreader_title db 'Open a text File',0
sz_csvreader_filter db 'Text files (*.txt, *.csv, *.prn)',0,'*.txt;*.csv;*.prn',0
db 'All files (*.*)',0,'*.*',0,0
sz_csvreader_defname db 0
sz_csvreader_defext db 0
sz_csvreader_button EQU 0
getfilename_path_csvreader TEXTEQU <filename_csvreader_path>
GETNAME_FLAGS_CSVREADER EQU 0
;// csv writer
GETFILENAME_CSVWRITER_FLAGS EQU OFN_HIDEREADONLY OR OFN_LONGNAMES OR OFN_EXPLORER OR OFN_ENABLEHOOK
sz_csvwriter_title db 'Open or Create a text file',0
sz_csvwriter_filter db 'Text files (*.txt, *.csv, *.prn)',0,'*.txt;*.csv;*.prn',0
db 'All files (*.*)',0,'*.*',0,0
sz_csvwriter_defext db 'txt',0,0
sz_csvwriter_defname EQU 0 ;// builds circuit name + .txt
sz_csvwriter_button EQU 0
getfilename_path_csvwriter TEXTEQU <filename_csvwriter_path>
GETNAME_FLAGS_CSVWRITER EQU 0
ALIGN 4
;// getfilename_table
getfilename_table LABEL GETFILENAME_TABLE
GETFILENAME_TABLE { GETFILENAME_OPEN_FLAGS,sz_open_title,sz_open_filter,sz_open_defext,sz_open_defname,sz_open_button,getfilename_path_open,GETNAME_FLAGS_OPEN }
GETFILENAME_TABLE { GETFILENAME_SAVEAS_FLAGS,sz_saveas_title,sz_saveas_filter,sz_saveas_defext,sz_saveas_defname,sz_saveas_button,getfilename_path_saveas,GETNAME_FLAGS_SAVEAS }
GETFILENAME_TABLE { GETFILENAME_PASTE_FLAGS,sz_paste_title,sz_paste_filter,sz_paste_defext,sz_paste_defname,sz_paste_button,getfilename_path_paste,GETNAME_FLAGS_PASTE }
GETFILENAME_TABLE { GETFILENAME_BITMAP_FLAGS,sz_bitmap_title,sz_bitmap_filter,sz_bitmap_defext,sz_bitmap_defname,sz_bitmap_button,getfilename_path_bitmap,GETNAME_FLAGS_BITMAP }
GETFILENAME_TABLE { GETFILENAME_PLUGIN_FLAGS,sz_plugin_title,sz_plugin_filter,sz_plugin_defext,sz_plugin_defname,sz_plugin_button,getfilename_path_plugin,GETNAME_FLAGS_PLUGIN }
GETFILENAME_TABLE { GETFILENAME_DATA_FLAGS,sz_data_title,sz_data_filter,sz_data_defext,sz_data_defname,sz_data_button,getfilename_path_data,GETNAME_FLAGS_DATA }
GETFILENAME_TABLE { GETFILENAME_READER_FLAGS,sz_reader_title,sz_reader_filter,sz_reader_defext,sz_reader_defname,sz_reader_button,getfilename_path_reader,GETNAME_FLAGS_READER }
GETFILENAME_TABLE { GETFILENAME_WRITER_FLAGS,sz_writer_title,sz_writer_filter,sz_writer_defext,sz_writer_defname,sz_writer_button,getfilename_path_writer,GETNAME_FLAGS_WRITER }
GETFILENAME_TABLE { GETFILENAME_CSVREADER_FLAGS,sz_csvreader_title,sz_csvreader_filter,sz_csvreader_defext,sz_csvreader_defname,sz_csvreader_button,getfilename_path_csvreader,GETNAME_FLAGS_CSVREADER }
GETFILENAME_TABLE { GETFILENAME_CSVWRITER_FLAGS,sz_csvwriter_title,sz_csvwriter_filter,sz_csvwriter_defext,sz_csvwriter_defname,sz_csvwriter_button,getfilename_path_csvwriter,GETNAME_FLAGS_CSVWRITER }
.CODE
;//________________________________________________________________________
;//
;// filename_GetFileName
;//
;// returns zero for cancel
;// returns 1 for filename_get_path is valid
;// except for choose plugin, which returns a list
;//
;//________________________________________________________________________
;// returns: eax = 0 for cancel
;//
;// if ( mode == ABOX_PLUGIN )
;//
;// filename_load_path is the single file name the user choose
;//
;// if ( mode == ABOX_PLUGIN )
;//
;// eax is a memory block containing the list of selected files
;// caller must parse these correctly
;// and memory_Free the returned pointer
;// filename_load_path is NOT effected
PROLOGUE_OFF
ASSUME_AND_ALIGN
filename_GetFileName PROC STDCALL uses esi edi ebx mode:dword
;// stack
;// ret mode
;// 00 04
;// check some parameters