Version:
~ [ 10.0 ] ~
** Warning: Cannot open xref database.
1
2 /* $Id: claycallbacks.c,v 1.4 2005/01/11 22:48:04 andreradke Exp $ */
3
4 /******************************************************************************
5
6 UserLand Frontier(tm) -- High performance Web content management,
7 object database, system-level and Internet scripting environment,
8 including source code editing and debugging.
9
10 Copyright (C) 1992-2004 UserLand Software, Inc.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
26 ******************************************************************************/
27
28 #include "frontier.h"
29 #include "standard.h"
30
31 #include "cursor.h"
32 #include "dialogs.h"
33 #include "error.h"
34 #include "file.h"
35 #include "fileloop.h"
36 #include "kb.h"
37 #include "memory.h"
38 #include "ops.h"
39 #include "strings.h"
40 #include "opinternal.h"
41 #include "claybrowserstruc.h"
42 #include "claybrowserexpand.h"
43 #include "claycallbacks.h"
44 #if odbbrowser
45 #include "lang.h"
46 #include "langinternal.h"
47 #include "langexternal.h"
48 #include "tableverbs.h"
49 #include "tableinternal.h"
50 #include "tablestructure.h"
51 #endif
52
53
54
55 #if filebrowser
56
57 boolean claymakespec (tybrowservol vnum, tybrowserdir dirid, bigstring fname, tybrowserspec *pfs) {
58
59 return (filemakespec (vnum, dirid, fname, pfs));
60 } /*claymakespec*/
61
62 #endif
63
64 #if odbbrowser
65
66 boolean claymakespec (tybrowservol vnum, tybrowserdir dirid, bigstring fname, tybrowserspec *pfs) {
67
68 (*pfs).vRefNum = vnum;
69
70 (*pfs).parID = dirid;
71
72 copystring (fname, (*pfs).name);
73
74 return (dirid != 0L);
75 } /*claymakespec*/
76
77 #endif
78
79
80 #if odbbrowser
81
82 boolean claylookupvalue (const tybrowserspec *fs, tyvaluerecord *val, hdlhashnode * hnode) {
83
84 return (hashtablelookup ((*fs).parID, (*fs).name, val, hnode));
85 } /*claylookupvalue*/
86
87
88 boolean claycopyfile (const tybrowserspec *fsource, const tybrowserspec *fdest) {
89
90 /*
91 5.1b21 dmb: push/pop databases
92
93 5.1.4 dmb: hook, trap errors
94 */
95
96 tyvaluerecord val;
97 boolean fl;
98 Handle hpacked;
99 hdldatabaserecord hdatabase;
100 langerrormessagecallback savecallback;
101 ptrvoid saverefcon;
102 bigstring bspackerror;
103 hdlhashnode hnode;
104
105 fl = claylookupvalue (fsource, &val, &hnode);
106
107 if (!fl)
108 return (true); /*not fatal error; false is returned to caller*/
109
110 if (!flscriptrunning)
111 langhookerrors ();
112
113 langtraperrors (bspackerror, &savecallback, &saverefcon);
114
115 hdatabase = (*fsource).vRefNum;
116
117 if (hdatabase)
118 dbpushdatabase (hdatabase);
119
120 fl = langpackvalue (val, &hpacked, hnode);
121
122 if (hdatabase)
123 dbpopdatabase ();
124
125 if (!fl) /*error packing -- probably out of memory*/
126 goto exit;
127
128 hdatabase = (*fdest).vRefNum;
129
130 if (hdatabase)
131 dbpushdatabase (hdatabase);
132
133 fl = langunpackvalue (hpacked, &val);
134
135 if (hdatabase)
136 dbpopdatabase ();
137
138 disposehandle (hpacked);
139
140 opstartinternalchange ();
141
142 if (fl) {
143
144 fl = hashtableassign ((*fdest).parID, (*fdest).name, val);
145
146 if (!fl)
147 disposevaluerecord (val, true);
148 }
149
150 opendinternalchange ();
151
152 exit:
153
154 languntraperrors (savecallback, saverefcon, !fl);
155
156 if (!flscriptrunning)
157 langunhookerrors ();
158
159 if (!fl)
160 shellerrormessage (bspackerror);
161
162 return (fl);
163 } /*claycopyfile*/
164
165
166 boolean claycreatefile (const tybrowserspec *fs) {
167
168 tyvaluerecord val;
169 boolean fl;
170
171 initvalue (&val, novaluetype);
172
173 opstartinternalchange ();
174
175 fl = hashtableassign ((*fs).parID, (*fs).name, val);
176
177 opendinternalchange ();
178
179 return (fl);
180 } /*claycreatefile*/
181
182
183 boolean claydeletefile (const tybrowserspec *fs) {
184
185 boolean fl;
186
187 opstartinternalchange ();
188
189 fl = hashtabledelete ((*fs).parID, (ptrstring) (*fs).name);
190
191 opendinternalchange ();
192
193 return (fl);
194 } /*claydeletefile*/
195
196
197 boolean claymovefile (const tybrowserspec *fs, const tybrowserspec *fsto) {
198
199 tyvaluerecord val;
200 hdlhashtable hdest;
201 boolean fl;
202 hdlhashnode hnode;
203
204 if (!claygetdirid (fsto, &hdest)) {
205
206 langerrormessage ("\x1b" "destination must be a table");
207
208 return (false);
209 }
210
211 opstartinternalchange ();
212
213 pushhashtable ((*fs).parID);
214
215 fl = hashlookup ((*fs).name, &val, &hnode);
216
217 if (fl) {
218
219 // if ((*fs).parID == agentstable)
220
221 hashdelete ((*fs).name, false, false); /*don't toss the value*/
222 }
223
224
225 pophashtable ();
226
227 if (fl) {
228
229 fl = hashtableassign (hdest, (*fs).name, val);
230
231 /*
232 if (fl && (hdest == agentstable) {
233
234 hashtablelookupnode (hdest, (*fs).name, &hnode);
235
236 scriptinstallagent (hnode);
237 }
238 */
239 }
240
241 opendinternalchange ();
242
243 return (true);
244
245 } /*claymovefile*/
246
247 #endif
248
249 #if filebrowswer
250
251 static boolean filedeletevisit (bigstring bsitem, tyfileinfo *info, long refcon) {
252
253 tybrowserspec fs;
254
255 // if (stringlength (fs.name) == 0) /*defensive driving -- if you turn this off -- it could delete C source code in the program you're testing*/
256 // return (false);
257
258 claymakespec ((*info).vnum, (*info).dirid, bsitem, &fs);
259
260 return (filedelete (&fs));
261 } /*filedeletevisit*/
262
263
264 boolean clayemptyfilefolder (tybrowserspec *fsfolder) {
265
266 return (folderloop (fsfolder, true, &filedeletevisit, 0));
267 } /*clayemptyfilefolder*/
268
269 #endif
270
271 #if odbbrowser
272
273 boolean clayemptyfilefolder (tybrowserspec *fsfolder) {
274
275 return (emptyhashtable ((*fsfolder).parID, true) > 0);
276 } /*clayemptyfilefolder*/
277
278
279 #endif
280
281
282 #if filebrowser
283
284 boolean claygetdirid (const tybrowserspec * fsfolder, tybrowserdir *dirid) {
285
286 CInfoPBRec pb;
287
288 if (!getmacfileinfo (fsfolder, &pb))
289 return (false);
290
291 *dirid = pb.dirInfo.ioDrDirID;
292
293 return (true);
294 } /*claygetdirid*/
295
296 #endif
297
298 #if odbbrowser
299
300 static boolean claygetfolder (const tybrowserspec * fsfolder, tybrowserdir *dirid, boolean flinmemory) {
301
302 tyvaluerecord val;
303 hdlhashnode hnode;
304
305 if ((*fsfolder).parID == nil) {
306
307 assert (equalstrings ((*fsfolder).name, nameroottable));
308
309 *dirid = roottable;
310
311 goto tagandexit;
312 }
313
314 if (isemptystring ((*fsfolder).name)) {
315
316 *dirid = (*fsfolder).parID;
317
318 goto tagandexit;
319 }
320
321 if (!claylookupvalue (fsfolder, &val, &hnode))
322 return (false);
323
324 if (flinmemory) {
325
326 hdlexternalvariable hv = (hdlexternalvariable) val.data.externalvalue;
327
328 if (!(**hv).flinmemory)
329 return (false);
330 }
331
332 if (!tablevaltotable (val, dirid, hnode))
333 return (false);
334
335 tagandexit:
336
337 // (***dirid).flmayaffectdisplay = true; // let tablesymbol calls know we may care
338
339 return (true);
340 } /*claygetfolder*/
341
342
343 boolean claygetdirid (const tybrowserspec * fsfolder, tybrowserdir *dirid) {
344
345 return (claygetfolder (fsfolder, dirid, false));
346 } /*claygetdirid*/
347
348
349 boolean claygetinmemorydirid (const tybrowserspec * fsfolder, tybrowserdir *dirid) {
350
351 return (claygetfolder (fsfolder, dirid, true));
352 } /*claygetinmemorydirid*/
353
354 #endif
355
356
357 #if filebrowser
358
359 static boolean filegetprefsspec (bigstring fname, tybrowserspec *fsprefs) {
360
361 short vnum;
362 long dirid;
363 OSErr ec;
364
365 ec = FindFolder (kOnSystemDisk, kPreferencesFolderType, kCreateFolder, &vnum, &dirid);
366
367 if (oserror (ec))
368 return (false);
369
370 claymakespec (vnum, dirid, fname, fsprefs);
371
372 return (true);
373 } /*filegetprefsspec*/
374
375 #endif
376
377 #if 0 //odbbrowser
378
379 static boolean xxxfilegetprefsspec (bigstring fname, tybrowserspec *fsprefs) {
380
381 tybrowservol vnum;
382 tybrowserdir dirid;
383
384 vnum = databasedata; // we really should use a different record, not an fsspec
385
386 dirid = internaltable;
387
388 claymakespec (vnum, dirid, fname, fsprefs);
389
390 return (true);
391 } /*filegetprefsspec*/
392
393 #endif
394
395
396 #if filebrowser
397
398 static boolean filecreatefolder (const tybrowserspec * fsfolder) {
399
400 OSErr ec;
401 long folderid;
402
403 ec = FSpDirCreate (fsfolder, smSystemScript, &folderid);
404
405 return (true);
406 } /*filecreatefolder*/
407
408 #endif
409
410 #if odbbrowser
411
412 static boolean filecreatefolder (tybrowserspec * fsfolder) {
413
414 tybrowserdir folderid;
415
416 return (tablenewsystemtable ((*fsfolder).parID, (*fsfolder).name, (tybrowserdir *) &folderid));
417 } /*filecreatefolder*/
418
419 #endif
420
421 boolean claygetsubitemspec (tybrowserspec *fsfolder, bigstring fname, tybrowserspec *fssubitem) {
422
423 /*
424 dmb 9/20/93: must return false if claymakespec returns false
425 */
426
427 tybrowserdir dirid;
428
429 if (!claygetdirid (fsfolder, &dirid))
430 return (false);
431
432 return (claymakespec ((*fsfolder).vRefNum, dirid, fname, fssubitem));
433 } /*claygetsubitemspec*/
434
435
436 boolean claygetspecialfolder (void *foldername, boolean flcreate, tybrowserspec *fsspecialfolder) {
437
438 /*
439 a bottleneck for finding special Clay Basket folders. it actually works
440 for files too -- it's used to locate the preferences file.
441
442 if flcreate is true, and the folder doesn't exist, we create it.
443
444 DW 3/12/95: Add another level, the Clay Basket folder is contained within
445 the UserLand folder.
446 */
447
448 #if filebrowser
449 tybrowserspec fsuserland, fsfolder;
450
451 if (!filegetprefsspec ("\x08" "UserLand", &fsuserland))
452 return (false);
453
454 if (!clayfileexists (&fsuserland, &flfolder)) {
455
456 if (!filecreatefolder (&fsuserland))
457 return (false);
458 }
459
460 if (!claygetsubitemspec (&fsuserland, "\x12" "Clay Basket Folder", &fsfolder))
461 return (false);
462
463 if (!clayfileexists (&fsfolder, &flfolder)) {
464
465 if (!filecreatefolder (&fsfolder))
466 return (false);
467 }
468
469 if (!claygetsubitemspec (&fsfolder, foldername, fsspecialfolder))
470 return (false);
471 #endif
472
473 #if odbbrowser
474 static hdlhashtable hclaybaskettable = nil;
475
476 if (hclaybaskettable == nil) { // first time called
477
478 if (!newhashtable (&hclaybaskettable))
479 return (false);
480 }
481
482 claymakespec (nil, hclaybaskettable, foldername, fsspecialfolder);
483 #endif
484
485 if (!flcreate)
486 return (true);
487
488 if (!clayfileexists (fsspecialfolder, &flfolder)) /*doesn't exist*/
489 return (filecreatefolder (fsspecialfolder));
490
491 return (true);
492 } /*claygetspecialfolder*/
493
494 #if filebrowser
495
496 void fileinfotobrowserinfo (tyfileinfo *fileinfo, tybrowserinfo *browserinfo) {
497
498 (*browserinfo).flfolder = (*fileinfo).flfolder;
499
500 (*browserinfo).flvolume = (*fileinfo).flvolume;
501
502 (*browserinfo).fllocked = (*fileinfo).fllocked;
503
504 (*browserinfo).flhardwarelock = (*fileinfo).flhardwarelock;
505
506 (*browserinfo).flremotevolume = (*fileinfo).flremotevolume;
507
508 (*browserinfo).flstationery = (*fileinfo).flstationery;
509
510 (*browserinfo).flalias = (*fileinfo).flalias;
511
512 (*browserinfo).flejectable = (*fileinfo).flejectable;
513
514 (*browserinfo).flnamelocked = (*fileinfo).flnamelocked;
515
516 (*browserinfo).flcustomicon = (*fileinfo).flcustomicon;
517
518 (*browserinfo).filetype = (*fileinfo).filetype;
519
520 (*browserinfo).filecreator = (*fileinfo).filecreator;
521
522 (*browserinfo).timecreated = (*fileinfo).timecreated;
523
524 (*browserinfo).timemodified = (*fileinfo).timemodified;
525
526 (*browserinfo).vnum = (*fileinfo).vnum;
527
528 (*browserinfo).dirid = (*fileinfo).dirid;
529
530 (*browserinfo).suffixnum = (*fileinfo).suffixnum; // dmb 5.0b9 - was: 0;
531
532 (*browserinfo).ixlabel = (*fileinfo).ixlabel;
533
534 (*browserinfo).folderview = (*fileinfo).folderview;
535
536 if ((*browserinfo).flfolder)
537 (*browserinfo).filesize = (*fileinfo).ctfiles;
538 else
539 (*browserinfo).filesize = (*fileinfo).sizedatafork + (*fileinfo).sizeresourcefork;
540 } /*fileinfotobrowserinfo*/
541
542 #endif
543
544
545 #if filebrowser
546
547
548 typedef struct tycallbackinfo {
549
550 tyclayfileloopcallback callback;
551
552 long refcon;
553 } tycallbackinfo;
554
555
556 static boolean clayfolderexpandvisit (bigstring bsitem, tyfileinfo *info, long refcon) {
557
558 tycallbackinfo *cb = (tycallbackinfo *) refcon;
559 tybrowserinfo browserinfo;
560
561 if ((*info).flinvisible && (!clayprefs.showinvisibles)) /*invisible file/folder, don't show it*/
562 return (true);
563
564 fileinfotobrowserinfo (info, &browserinfo);
565
566 return ((*(*cb).callback) (bsitem, &browserinfo, (*cb).refcon));
567 } /*clayfolderexpandvisit*/
568
569 boolean clayfolderloop (const tybrowserspec *pfs, boolean flreverse, tyclayfileloopcallback filecallback, long refcon) {
570
571 tycallbackinfo callbackinfo;
572
573 callbackinfo.callback = filecallback;
574 callbackinfo.refcon = refcon;
575
576 return (folderloop (pfs, flreverse, clayfolderexpandvisit, (long) &callbackinfo));
577 } /*clayfolderloop*/
578
579 #endif
580
581
582 #if odbbrowser
583
584 typedef struct tycallbackinfo {
585
586 hdldatabaserecord hdatabase;
587
588 hdlhashtable hparenttable;
589
590 tyclayfileloopcallback callback;
591
592 long refcon;
593 } tycallbackinfo;
594
595
596 static boolean clayfolderloopvisit (bigstring bsname, hdlhashnode hnode, tyvaluerecord val, ptrvoid refcon) {
597
598 /*
599 5.0a3 dmb: set flmayaffectdisplay for the parent table
600
601 5.0a17 dmb: no, let clayfolderloop do it, once, even if table is empty
602 */
603
604 tybrowserspec fs;
605 tybrowserinfo info;
606 tycallbackinfo *cbinfo = (tycallbackinfo *) refcon;
607
608 fs.vRefNum = (*cbinfo).hdatabase;
609
610 fs.parID = (*cbinfo).hparenttable;
611
612 copystring (bsname, fs.name);
613
614 claygetfileinfo (&fs, &info);
615
616 return (!(*(*cbinfo).callback) (bsname, &info, (*cbinfo).refcon));
617 } /*clayfolderloopvisit*/
618
619
620 boolean clayfolderloop (const tybrowserspec *pfs, boolean flreverse, tyclayfileloopcallback filecallback, long refcon) {
621
622 /*
623 5.0.2b21 dmb: set hdatafield according to pfs; no more databasedata refs
624 */
625
626 hdlhashtable htable;
627 tycallbackinfo fileloopcallbackinfo;
628
629 if (!claygetdirid (pfs, &htable))
630 return (false);
631
632 (**htable).flmayaffectdisplay = true;
633
634 fileloopcallbackinfo.hdatabase = (*pfs).vRefNum;
635
636 fileloopcallbackinfo.hparenttable = htable;
637
638 fileloopcallbackinfo.callback = filecallback;
639
640 fileloopcallbackinfo.refcon = refcon;
641
642 return (!hashsortedinversesearch (htable, clayfolderloopvisit, &fileloopcallbackinfo));
643 } /*clayfolderloop*/
644
645 #endif
646
647
648 boolean claygetfileinfo (const tybrowserspec *fs, tybrowserinfo *info) {
649
650 /*
651 5.0a3 dmb: side effect: set flmayaffectdisplay flags
652 */
653
654 #if filebrowser
655
656 tyfileinfo fileinfo;
657
658 if (!filegetinfo (fs, &fileinfo))
659 return (false);
660
661 fileinfotobrowserinfo (&fileinfo, info);
662
663 return (true);
664
665 #endif
666
667 #if odbbrowser
668
669 tyvaluerecord val;
670 hdlexternalvariable hv;
671 hdlhashtable ht;
672 hdlhashnode hnode;
673 long ct;
674
675 clearbytes (info, sizeof (tybrowserinfo));
676
677 if ((*fs).parID == nil) { // a root
678
679 (*info).flfolder = true;
680
681 hashcountitems (roottable, &ct);
682
683 (*info).filesize = ct;
684 }
685 else {
686 if (claylookupvalue (fs, &val, &hnode)) {
687
688 if (val.valuetype == externalvaluetype) {
689
690 hv = (hdlexternalvariable) val.data.externalvalue;
691
692 (**hv).flmayaffectdisplay = true;
693
694 if (istablevariable (hv)) {
695
696 (*info).flfolder = true;
697
698 (*info).filesize = 1; // can expand; don't care about actual #
699
700 if ((**hv).flinmemory) {
701
702 if (langexternalvaltotable (val, &ht, hnode))
703 (**ht).flmayaffectdisplay = true;
704 }
705 }
706 }
707
708 // langgetvalsize (val, &(*info).filesize);
709 }
710 }
711
712 /* *** replace fields with odb-specific info
713 (*fs).filetype = (*fileinfo).filetype;
714
715 (*fs).filecreator = (*fileinfo).filecreator;
716
717 (*fs).timecreated = (*fileinfo).timecreated;
718
719 (*fs).timemodified = (*fileinfo).timemodified;
720 */
721
722 (*info).vnum = (*fs).vRefNum;
723
724 (*info).dirid = (*fs).parID;
725
726 (*info).suffixnum = /*(*fileinfo).suffixnum*/ 0;
727
728 /*
729 (*fs).ixlabel = (*fileinfo).ixlabel;
730
731 (*fs).folderview = (*fileinfo).folderview;
732
733 if ((*fs).flfolder)
734 (*fs).filesize = (*fileinfo).ctfiles;
735 else
736 (*fs).filesize = (*fileinfo).sizedatafork + (*fileinfo).sizeresourcefork;
737 */
738
739 return (true);
740
741 #endif
742 } /*claygetfileinfo*/
743
744
745 boolean claygetfilename (const tybrowserspec *pfs, bigstring name) {
746
747 #if filebrowser
748
749 return (filegetfilename (pfs, name));
750
751 #endif
752
753 #if odbbrowser
754
755 copystring ((*pfs).name, name);
756
757 return (true);
758
759 #endif
760 } /*claygetfilename*/
761
762
763 boolean clayrenamefile (tybrowserspec *fs, hdlheadrecord headnode) {
764
765 /*
766 6.2b16 AR. tablesetitemname now takes a headnode param instead of a bigstring
767 */
768
769 #if filebrowser
770
771 bigstring bsnew;
772
773 opgetheadstring (headnode, bsnew);
774
775 return (renamefile (fs, bsnew));
776
777 #endif
778
779 #if odbbrowser
780
781 boolean fl;
782
783 opstartinternalchange ();
784
785 fl = tablesetitemname ((*fs).parID, (*fs).name, headnode, true);
786
787 opendinternalchange ();
788
789 return (fl);
790 #endif
791 } /*clayrenamefile*/
792
793
794 #if filebrowser
795
796 static boolean expanddiskvisit (bigstring bsitem, tyfileinfo *info, long refcon) {
797
798 /*
799 dmb 9/24/93: need this layer between the diskloop and browserexpandvisit
800 to completely fill out the info record. most clients of diskloop don't
801 care about the fields that can only be set from the root directory, but
802 we do.
803 */
804
805 tybrowserspec fsdiskroot;
806
807 if (filemakespec ((*info).vnum, (*info).dirid, bsitem, &fsdiskroot)) {
808
809 if (filegetinfo (&fsdiskroot, info)) {
810
811 tybrowserinfo browserinfo;
812
813 fileinfotobrowserinfo (info, &browserinfo);
814
815 browserexpandvisit (bsitem, &browserinfo, refcon);
816 }
817 }
818
819 return (true);
820 } /*expanddiskvisit*/
821
822 #endif
823
824 #if 0
825
826 static boolean xxxclayinitializeoutline (void) {
827
828
829 #if filebrowser
830 tyexpandinfo expandinfo;
831 expandinfo.hparent = nil; /*special case, see browserfindinsertionpoint*/
832
833 expandinfo.ctlevels = 1;
834
835 expandinfo.flsettmpbits = false;
836
837 return (diskloop (&expanddiskvisit, (long) &expandinfo));
838 #endif
839
840 #if odbbrowser
841 tybrowserspec fsroot;
842 tybrowserinfo browserinfo;
843 tyexpandinfo expandinfo;
844 expandinfo.hparent = nil; /*special case, see browserfindinsertionpoint*/
845
846 expandinfo.ctlevels = 1;
847
848 expandinfo.flsettmpbits = false;
849
850 fsroot.vRefNum = databasedata;
851
852 /*
853 fsroot.parID = roottable;
854
855 setemptystring (fsroot.name);
856 */
857
858 fsroot.parID = nil;
859
860 copystring (nameroottable, fsroot.name);
861
862 claygetfileinfo (&fsroot, &browserinfo);
863
864 return (clayfolderloop (&fsroot, false, browserexpandvisit, (long) &expandinfo));
865
866 #endif
867 } /*clayinitializeoutline*/
868
869 #endif
870
871
872 #if filebrowser
873
874 static void pushadjective (bigstring adjective, bigstring bs) {
875
876 bigstring adj;
877
878 copystring (adjective, adj); /*we might modify it*/
879
880 if (stringlength (bs) > 0) {
881
882 pushstring ("\x01" " ", bs);
883
884 alllower (adj);
885 }
886
887 pushstring (adj, bs);
888 } /*pushadjective*/
889
890
891 static void claygetfilekindstring (const tybrowserinfo *info, bigstring bs) {
892
893 // FSSpec appspec;
894
895 if ((*info).flvolume) {
896
897 setstringlength (bs, 0);
898
899 if ((*info).flejectable)
900 pushadjective ("\x09" "Removable", bs);
901
902 if ((*info).flhardwarelock)
903 pushadjective ("\x09" "Read-only", bs);
904
905 if ((*info).flremotevolume)
906 pushadjective ("\x06" "Shared", bs);
907
908 if (stringlength (bs) > 0)
909 pushstring ("\x05" " disk", bs);
910 else
911 copystring ("\x04" "Disk", bs);
912
913 return;
914 }
915
916 if ((*info).flfolder) {
917
918 copystring ("\x06" "Folder", bs);
919
920 return;
921 }
922
923 if ((*info).flalias) {
924
925 copystring ("\x05" "Alias", bs);
926
927 return;
928 }
929
930 switch ((*info).filecreator) {
931
932 case 'DMGR': case 'ERIK':
933 copystring ("\x14" "Desktop Manager file", bs);
934
935 return;
936
937 case 'MACS':
938 copystring ("\x0f" "System Software", bs);
939
940 return;
941 } /*switch*/
942
943 switch ((*info).filetype) {
944
945 case 'APPL':
946 copystring ("\x13" "Application program", bs);
947
948 return;
949
950 case 'cdev':
951 copystring ("\x0d" "Control Panel", bs);
952
953 return;
954
955 case 'INIT': case 'appe': case 'fext': case 'adev':
956 copystring ("\x10" "System Extension", bs);
957
958 return;
959
960 case 'thng':
961 copystring ("\x10" "System Component", bs);
962
963 return;
964
965 case 'PRER': case 'PRES':
966 copystring ("\x11" "Chooser Extension", bs);
967
968 return;
969
970 case 'FFIL':
971 copystring ("\x0d" "Font Suitcase", bs);
972
973 return;
974
975 case 'dbgr':
976 copystring ("\x08" "Debugger", bs);
977
978 return;
979
980 case 'dfil':
981 copystring ("\x0e" "Desk Accessory", bs);
982
983 return;
984 } /*switch*/
985 #if 0
986 if (clayfindapp ((*info).filecreator, &appspec, (*info).vnum)) {
987
988 if (stringlength (appspec.name) > 0) {
989
990 copystring (appspec.name, bs);
991
992 pushstring ("\x09" " document", bs);
993
994 return;
995 }
996 }
997 else { /*DW 9/14/93 -- add it to the cache -- avoid future delays*/
998
999 addapptocache ((*info).filecreator, nil);
1000 }
1001 #endif
1002
1003 copystring ("\x08" "document", bs);
1004 } /*claygetfilekindstring*/
1005
1006
1007 static void claygetfatsizestring (const tybrowserinfo *browserinfo, bigstring bs) {
1008
1009 setstringlength (bs, 0);
1010
1011 if ((*browserinfo).flvolume) {
1012
1013 tybrowserspec fs;
1014 tyfileinfo fileinfo;
1015
1016 if (!claymakespec ((*browserinfo).vnum, 0, "\0", &fs))
1017 return;
1018
1019 if (!filegetinfo (&fs, &fileinfo))
1020 return;
1021
1022 numbertostring (fileinfo.cttotalbytes, bs);
1023
1024 return;
1025 }
1026
1027 if ((*browserinfo).flfolder) {
1028
1029 short ctfiles = (*browserinfo).filesize;
1030
1031 numbertostring (ctfiles, bs);
1032
1033 pushstring ("\x05" " item", bs);
1034
1035 if (ctfiles != 1)
1036 pushstring ("\x01" "s", bs);
1037
1038 return;
1039 }
1040
1041 numbertostring ((*browserinfo).filesize, bs);
1042 } /*claygetfatsizestring*/
1043
1044
1045 #endif
1046
1047 boolean browsertextchanged (hdlheadrecord hnode, bigstring origname) {
1048
1049 /*
1050 dmb 9/24/93: don't call browserloadnode on hnode itself. renaming a
1051 file doesn't change its mod date, so it shouldn't need reloading. if
1052 something else has changed, say because something SpaceSaver took some
1053 other action in response to the rename, reloading the node isn't
1054 thorough enough. it will just prevent the idle loop from picking up
1055 the change.
1056
1057 5.0d18 dmb: don't resort node based on text change
1058
1059 5.0b18 dmb: don't check line length here, with bogus message. it will
1060 be checked by rename file
1061
1062 6.2b16 AR: clayrenamefile now takes a hdlheadrecord instead of a bigstring
1063 */
1064
1065 tybrowserspec fs;
1066 bigstring newname;
1067 tybrowserinfo info;
1068
1069 claygetfilespec (hnode, &fs);
1070
1071 if (!browsergetrefcon (hnode, &info)) // it's a new node
1072 return (browserlineinserted (hnode));
1073
1074 opgetheadstring (hnode, newname);
1075
1076 /*
1077 if (!browserchecklinelength (stringlength (newname), newname))
1078 return (false);
1079 */
1080
1081 if (!info.flvolume)
1082 copystring (origname, fs.name);
1083
1084 if (!clayrenamefile (&fs, hnode))
1085 return (false);
1086
1087 (**hnode).tmpbit2 = false; //user gave it a name, no longer temp
1088
1089 langexternalpleasesave (fs.parID, newname); // 5.1.4
1090
1091 // if (clayprefs.addonnamechange)
1092 // addnodetohistorymenu (hnode);
1093
1094 if (false) //!(**hnode).tmpbit) /*special for find & replace, see findsetheadstring in clayfind.c*/
1095 browserinsertagain (hnode);
1096
1097 browserloadnode ((**hnode).headlinkleft); /*mod date changed*/
1098
1099 return (true);
1100 } /*browsertextchanged*/
1101
1102
1103
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.