1 #include "filesystems.h"
3 struct TagItem DummyTags
[] = { TAG_DONE
, };
5 /* define some nonglobal data that can be used by the display hook */
7 void strcrem(char *s
, char *d
, char c
)
10 if (*s
!= c
) *d
++= *s
;
16 WORD
AskChoiceNew(char *title
, char *strg
, char *gadgets
, UWORD sel
, BOOL centered
)
20 Object
*button
, *bObject
, *selObject
;
25 char Buffer
[64], Buffer1
[64];
29 app
= ApplicationObject
,
31 MUIA_Application_Title
, (IPTR
)"Requester",
32 MUIA_Application_Base
, (IPTR
)"WANDERER_REQ",
34 SubWindow
, (IPTR
)(win
= WindowObject
,
35 MUIA_Window_Title
, title
,
36 MUIA_Window_Activate
, TRUE
,
37 MUIA_Window_DepthGadget
, TRUE
,
38 MUIA_Window_SizeGadget
, FALSE
,
39 MUIA_Window_AppWindow
, FALSE
,
40 MUIA_Window_CloseGadget
, FALSE
,
41 MUIA_Window_Borderless
, FALSE
,
42 MUIA_Window_TopEdge
, MUIV_Window_TopEdge_Moused
,
43 MUIA_Window_LeftEdge
, MUIV_Window_LeftEdge_Moused
,
45 WindowContents
, (IPTR
)VGroup
,
46 Child
, (IPTR
)TextObject
,
49 MUIA_Background
, MUII_TextBack
,
50 MUIA_Text_PreParse
, (IPTR
)"\33c",
51 MUIA_Text_Contents
, (IPTR
)strg
,
53 Child
, (IPTR
)(bObject
= HGroup
,End
),
67 old
= SplitName(gadgets
, '|', Buffer
, old
, sizeof(Buffer
));
68 if (old
== -1) back
= 10;
69 strcrem(Buffer
, Buffer1
, '_');
70 button
= SimpleButton(Buffer1
);
73 if ((back
-10) == sel
) selObject
= button
;
74 set(button
, MUIA_CycleChain
, 1);
75 DoMethod(bObject
, MUIM_Group_InitChange
);
76 DoMethod(bObject
, OM_ADDMEMBER
, button
);
77 DoMethod(bObject
, MUIM_Group_ExitChange
);
78 DoMethod(button
,MUIM_Notify
,MUIA_Pressed
, FALSE
, app
,2,MUIM_Application_ReturnID
,back
);
87 set (win
, MUIA_Window_TopEdge
, MUIV_Window_TopEdge_Centered
);
88 set (win
, MUIA_Window_LeftEdge
, MUIV_Window_LeftEdge_Centered
);
90 if (selObject
) set(win
, MUIA_Window_ActiveObject
, selObject
);
91 set(win
,MUIA_Window_Open
,TRUE
);
95 id
= DoMethod(app
,MUIM_Application_Input
,&signals
);
99 case MUIV_Application_ReturnID_Quit
:
139 if (running
&& signals
) Wait(signals
);
141 set(win
,MUIA_Window_Open
,FALSE
);
142 MUI_DisposeObject(app
);
147 WORD
AskChoice(char *title
, char *strg
, char *gadgets
, UWORD sel
)
149 return AskChoiceNew(title
, strg
, gadgets
, sel
, FALSE
);
152 WORD
AskChoiceCentered(char *title
, char *strg
, char *gadgets
, UWORD sel
)
154 return AskChoiceNew(title
, strg
, gadgets
, sel
, TRUE
);
157 char *combinePath(APTR pool
, char *path
, char *file
)
161 if ((path
== NULL
) || (file
== NULL
)) return NULL
;
162 if (strlen(path
) == NULL
) return NULL
;
163 if (strlen(file
) == NULL
) return NULL
;
165 l
= strlen(path
) + strlen(file
) + 1;
166 if (path
[strlen(path
)-1] != '/') l
++;
168 if (pool
== NULL
) out
= AllocVec(l
, MEMF_CLEAR
);
169 else out
= AllocPooled(pool
, l
);
174 AddPart(out
, file
, l
);
179 char *allocPath(APTR pool
, char *str
)
190 for (l
=0; s0
!= s1
; s0
++,l
++);
192 s
= AllocPooled(pool
, l
+1);
193 if (s
) strncpy(s
, str
, l
);
198 void freeString(APTR pool
, char *str
)
205 FreePooled(pool
, str
, strlen(str
)+1);
210 ** allocates memory for a string and copies them to the new buffer
212 ** inputs: str source string
213 ** return: char pointer to string or NULL
217 char *allocString(APTR pool
, char *str
)
222 if (str
== NULL
) return NULL
;
227 b
= (char*) AllocVec(l
+1, MEMF_CLEAR
);
228 else b
= (char*) AllocPooled(pool
, l
+1);
230 if (b
&& (l
>0)) strncpy (b
, str
, l
);
234 void InfoRename(APTR pool
, char *from
, char *to
)
236 char *frominfo
, *toinfo
;
238 if ((from
== NULL
) || (to
== NULL
)) return;
240 frominfo
= AllocPooled(pool
, strlen(from
)+6);
244 strncpy (frominfo
, from
, strlen(from
));
245 strcat(frominfo
,".info");
246 toinfo
= AllocPooled(pool
, strlen(to
)+6);
250 strncpy (toinfo
, to
, strlen(to
));
251 strcat(toinfo
,".info");
252 if (Rename(from
, to
)) Rename(frominfo
, toinfo
);
253 freeString(pool
, toinfo
);
255 freeString(pool
, frominfo
);
259 char *allocPathFromLock(APTR pool
, BPTR lock
)
264 pathb
= AllocPooled(pool
, PATHBUFFERSIZE
);
267 if (NameFromLock(lock
, pathb
, PATHBUFFERSIZE
))
269 path
= allocString(pool
, pathb
);
271 FreePooled(pool
, pathb
, PATHBUFFERSIZE
);
277 char *CombineString(char *format
, ...) {
281 char *s
, *s1
, *str
, *p
;
286 while ((s
= strstr(s
,"%s")) != NULL
) {cnt
++; s
++; }
290 len
= strlen(format
) - 2*cnt
;
291 va_start(ap
, format
);
296 p
= va_arg(ap
, char *);
303 back
= AllocVec(len
, MEMF_CLEAR
);
308 va_start(ap
, format
);
309 while ((s1
= strstr(s
, "%s")) != NULL
)
311 p
= va_arg(ap
, char *);
313 strncpy(str
, s
, len
);
316 strncpy(str
, p
, strlen(p
));
319 if (s
) strncpy(str
, s
, strlen(s
));
327 ULONG
isPathRecursive(APTR pool
, char *source
, char *destination
)
329 BPTR srcLock
, destLock
;
334 srcLock
= Lock(source
, SHARED_LOCK
);
337 destLock
= Lock(destination
, SHARED_LOCK
);
340 p1
= allocPathFromLock(pool
, srcLock
);
343 p2
= allocPathFromLock(pool
, destLock
);
346 if (strstr(p2
, p1
) == p2
) back
= PATH_RECURSIVE
; else back
= PATH_NONRECURSIVE
;
348 freeString(pool
, p2
);
350 freeString(pool
, p1
);
359 BOOL
FileExists(char *name
)
367 win
= ((struct Process
*) t
)->pr_WindowPtr
;
368 ((struct Process
*) t
)->pr_WindowPtr
= (APTR
) -1; //disable error requester
371 nLock
= Lock(name
, SHARED_LOCK
);
377 ((struct Process
*) t
)->pr_WindowPtr
= win
; //enable error requester
381 LONG
GetFileLength(char *name
)
389 win
= ((struct Process
*) t
)->pr_WindowPtr
;
390 ((struct Process
*) t
)->pr_WindowPtr
= (APTR
) -1; //disable error requester
392 in
= Open(name
, MODE_OLDFILE
);
394 Seek(in
, 0, OFFSET_END
);
395 info
= Seek(in
, 0, OFFSET_BEGINNING
);
398 ((struct Process
*) t
)->pr_WindowPtr
= win
; //enable error requester
402 void DisposeFileInformations(APTR pool
, struct FileInfo
*fi
)
404 if (fi
->comment
) freeString(pool
, fi
->comment
);
408 BOOL
GetFileInformations(APTR pool
, char *name
, struct FileInfo
*fi
)
410 struct FileInfoBlock
*FIB
;
419 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
422 nLock
= Lock(name
, ACCESS_READ
);
425 Success2
= Examine(nLock
,FIB
);
429 fi
->len
= FIB
->fib_Size
;
430 if (strlen(FIB
->fib_Comment
) > 0) fi
->comment
= allocString(pool
, FIB
->fib_Comment
);
431 fi
->protection
= FIB
->fib_Protection
;
435 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
440 LONG
GetFileInfo(char *name
)
442 struct FileInfoBlock
*FIB
;
448 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
451 nLock
= Lock(name
, ACCESS_READ
);
454 Success2
= Examine(nLock
,FIB
);
458 if (FIB
->fib_DirEntryType
>0) info
|= FILEINFO_DIR
;
459 if ((FIB
->fib_Protection
& FIBF_DELETE
) != 0) info
|= FILEINFO_PROTECTED
;
460 if ((FIB
->fib_Protection
& FIBF_WRITE
) != 0) info
|= FILEINFO_WRITE
;
464 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
469 LONG
GetProtectionInfo(char *name
)
471 struct FileInfoBlock
*FIB
;
477 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
480 nLock
= Lock(name
, ACCESS_READ
);
483 Success2
= Examine(nLock
,FIB
);
486 info
= FIB
->fib_Protection
;
490 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
495 char *GetCommentInfo(APTR pool
, char *name
)
497 struct FileInfoBlock
*FIB
;
504 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
507 nLock
= Lock(name
, ACCESS_READ
);
510 Success2
= Examine(nLock
,FIB
);
513 info
= allocString(pool
, (char*) &FIB
->fib_Comment
);
517 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
522 BOOL
deleteFile(char *file
) {
527 BOOL
copyFile(APTR pool
, char *file
, char *destpath
, struct FileInfoBlock
*fileinfo
, struct Hook
*displayHook
, struct dCopyStruct
*display
) {
528 struct FileInfoBlock
*fib
;
531 LONG bufferlen
= COPYLEN
;
538 if (display
!= NULL
) display
->totallen
= 0;
539 if (display
!= NULL
) display
->actlen
= 0;
542 filelen
= fileinfo
->fib_Size
;
543 if (fileinfo
->fib_Size
<= COPYLEN
) bufferlen
= fileinfo
->fib_Size
;
544 if (bufferlen
< 8192) bufferlen
= 8192;
549 fib
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
552 nLock
= Lock(file
, ACCESS_READ
);
555 if (Examine(nLock
,fib
) == 0)
561 filelen
= fib
->fib_Size
;
562 if (fib
->fib_Size
<= COPYLEN
) bufferlen
= fib
->fib_Size
;
563 if (bufferlen
< 8192) bufferlen
= 8192;
571 to
= combinePath(pool
, destpath
, FilePart(file
));
574 buffer
= AllocPooled(pool
, bufferlen
);
577 in
= Open(file
, MODE_OLDFILE
);
580 out
= Open(to
, MODE_NEWFILE
);
584 unsigned int difftime
= clock();
587 clen
= Read(in
, buffer
, bufferlen
);
588 if ((clen
!=0) && (clen
!= -1))
590 wlen
= Write(out
, buffer
,clen
);
593 display
->difftime
= clock() - difftime
;
594 if (display
->difftime
< 1) display
->difftime
= 1;
595 display
->actlen
= clen
;
596 display
->totallen
+= clen
;
597 display
->filelen
= filelen
;
600 display
->flags
|= ACTION_UPDATE
;
601 stop
= CallHook(displayHook
, (Object
*) display
, NULL
);
605 if (clen
!= wlen
) clen
= 0;
608 while ((clen
!=0) && (clen
!= -1) && !stop
);
616 SetComment(to
, fib
->fib_Comment
);
617 SetProtection(to
, fib
->fib_Protection
);
618 if (fileinfo
== NULL
) FreeDosObject (DOS_FIB
,(APTR
) fib
);
623 FreePooled(pool
, buffer
, bufferlen
);
625 freeString(pool
, to
);
630 BOOL
actionDir(APTR pool
, ULONG flags
, char *source
, char *dest
, BOOL quit
, UWORD delmode
, UWORD protectmode
, UWORD overwritemode
, struct Hook
*dHook
, struct Hook
*delHook
, APTR userdata
)
632 struct FileInfoBlock
*FIB
, *FIB2
;
633 struct dCopyStruct display
;
634 struct dCopyStruct delDisplay
;
635 struct FileEntry
*fe
, *fef
, *fel
;
637 BPTR NewLock
, cDir
, nDir
, nLock
;
638 WORD dmode
, pmode
, omode
, dm
, pm
, om
;
639 ULONG Success
, Success1
, Success2
, DosError
, len
;
640 char *dname
, *comment
, *dpath
;
641 BOOL del
, created
, unprotect
, failure
;
642 BOOL stop
, overwrite
;
645 if (quit
) return TRUE
;
647 display
.userdata
= userdata
;
648 delDisplay
.userdata
= userdata
;
651 omode
= overwritemode
;
657 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
660 FIB2
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
663 NewLock
= Lock(source
,ACCESS_READ
);
666 cDir
= CurrentDir(NewLock
);
668 Success1
=Examine(NewLock
,FIB
);
674 Success
=ExNext(NewLock
,FIB
);
676 if ((flags
& (ACTION_DELETE
| ACTION_COPY
)) == ACTION_DELETE
)
678 if (dmode
== DELMODE_NONE
) Success
= FALSE
;
681 if (Success
&& Success1
)
683 if (FIB
->fib_DirEntryType
>0)
688 if (((flags
& ACTION_COPY
) != 0) && dest
)
690 dname
= combinePath(pool
, dest
, FIB
->fib_FileName
);
694 nLock
= Lock(dname
, ACCESS_READ
);
697 Success2
= Examine(nLock
,FIB2
);
698 if (Success2
) if (FIB2
->fib_DirEntryType
>0) created
= TRUE
;
703 nDir
= CreateDir(dname
);
706 prot
= GetProtectionInfo(FIB
->fib_FileName
);
707 comment
= GetCommentInfo(pool
, FIB
->fib_FileName
);
708 if (comment
) SetComment(dname
, comment
);
709 SetProtection(dname
, prot
);
710 freeString(pool
, comment
);
721 if (delHook
&& (dmode
!= DELMODE_NONE
) && ((flags
& ACTION_DELETE
) != 0))
723 if ((dmode
== DELMODE_ASK
) || (dmode
== DELMODE_DELETE
) || (dmode
== DELMODE_ALL
) || (dmode
== DELMODE_NO
))
725 delDisplay
.spath
= FIB
->fib_FileName
;
726 delDisplay
.file
= NULL
;
728 delDisplay
.filelen
= FIB
->fib_Size
;
729 if (dmode
!= DELMODE_ALL
) dmode
= CallHook(delHook
, (Object
*) &delDisplay
, NULL
);
730 if ((dmode
== DELMODE_ALL
) || (dmode
== DELMODE_DELETE
))
734 info
= GetFileInfo(FIB
->fib_FileName
);
735 if ((info
& (FILEINFO_PROTECTED
|FILEINFO_WRITE
)) != 0)
737 if (pmode
!= DELMODE_NONE
)
740 (pmode
== DELMODE_ASK
) || (pmode
== DELMODE_DELETE
) ||
741 (pmode
== DELMODE_ALL
) || (pmode
== DELMODE_NO
)
744 delDisplay
.spath
= FIB
->fib_FileName
;
745 delDisplay
.file
= NULL
;
747 delDisplay
.filelen
= 0;
748 if (pmode
!= DELMODE_ALL
) pmode
= CallHook(delHook
, (Object
*) &delDisplay
, NULL
);
749 if ((pmode
== DELMODE_ALL
) || (pmode
== DELMODE_DELETE
))
751 SetProtection(FIB
->fib_FileName
, 0);
757 else unprotect
= TRUE
;
771 if (om
== DELMODE_NO
) om
= DELMODE_NONE
;
772 if (om
== DELMODE_DELETE
) om
= DELMODE_ALL
;
774 if (pm
== DELMODE_NO
) pm
= DELMODE_NONE
;
775 if (pm
== DELMODE_DELETE
) pm
= DELMODE_ALL
;
777 if (dm
== DELMODE_NO
) dm
= DELMODE_NONE
;
778 if (dm
== DELMODE_DELETE
) dm
= DELMODE_ALL
;
780 if (created
|| ((flags
& ACTION_DELETE
) !=0))
782 if (((dmode
== DELMODE_NO
) || (dmode
== DELMODE_NONE
)) && (flags
== ACTION_DELETE
))
788 quit
= actionDir(pool
, flags
, FIB
->fib_FileName
, dname
, quit
, dm
, pm
, om
, dHook
, delHook
, userdata
);
792 if (!quit
&& del
&& unprotect
)
794 if (FIB
->fib_FileName
)
796 len
= strlen(FIB
->fib_FileName
);
800 fe
= AllocPooled(pool
, sizeof(struct FileEntry
) + len
);
803 strcpy(fe
->name
, FIB
->fib_FileName
);
818 if (dname
) freeString(pool
, dname
);
824 display
.file
= FIB
->fib_FileName
;
825 display
.filelen
= FIB
->fib_Size
;
826 display
.spath
= source
;
827 display
.dpath
= dest
;
828 display
.flags
= (flags
&= ~ACTION_UPDATE
);
829 display
.totallen
= 0;
832 quit
= CallHook(dHook
, (Object
*) &display
, NULL
);
837 if (((flags
& ACTION_COPY
) != 0) && dest
)
839 dpath
= combinePath(pool
, dest
, FIB
->fib_FileName
);
842 info
= GetFileInfo(dpath
);
846 if (delHook
&& (omode
!= DELMODE_NONE
))
849 (omode
== DELMODE_ASK
) || (omode
== DELMODE_DELETE
) ||
850 (omode
== DELMODE_ALL
) || (omode
== DELMODE_NO
)
853 delDisplay
.spath
= dest
;
854 delDisplay
.file
= FIB
->fib_FileName
;
856 delDisplay
.filelen
= 0;
857 if (omode
!= DELMODE_ALL
) omode
= CallHook(delHook
, (Object
*) &delDisplay
, NULL
);
858 if ((omode
== DELMODE_ALL
) || (omode
== DELMODE_DELETE
))
860 if ((info
& (FILEINFO_PROTECTED
|FILEINFO_WRITE
)) !=0)
862 if (pmode
!= DELMODE_NONE
)
865 (pmode
== DELMODE_ASK
) || (pmode
== DELMODE_DELETE
) ||
866 (pmode
== DELMODE_ALL
) || (pmode
== DELMODE_NO
)
869 delDisplay
.spath
= dest
;
870 delDisplay
.file
= FIB
->fib_FileName
;
872 delDisplay
.filelen
= 0;
873 if (pmode
!= DELMODE_ALL
) pmode
= CallHook(delHook
, (Object
*) &delDisplay
, NULL
);
874 if ((pmode
== DELMODE_ALL
) || (pmode
== DELMODE_DELETE
))
877 SetProtection(dpath
, 0);
882 else overwrite
= TRUE
;
888 if (dpath
) freeString(pool
, dpath
);
892 if (!quit
&& ((flags
& ACTION_COPY
) !=0) && overwrite
)
894 display
.flags
= (flags
&= ~ACTION_UPDATE
);
895 failure
= copyFile(pool
, FIB
->fib_FileName
, dest
, FIB
, dHook
, &display
);
898 if (failure
&& !quit
)
902 delDisplay
.spath
= source
;
903 delDisplay
.file
= FIB
->fib_FileName
;
905 delDisplay
.filelen
= 0;
906 if (CallHook(delHook
, (Object
*) &delDisplay
, NULL
) == ACCESS_SKIP
)
907 quit
= FALSE
; else quit
= TRUE
;
912 if (!quit
&& delHook
&& (dmode
!= DELMODE_NONE
) && ((flags
& ACTION_DELETE
) !=0))
915 (dmode
== DELMODE_ASK
) || (dmode
== DELMODE_DELETE
) ||
916 (dmode
== DELMODE_ALL
) || (dmode
== DELMODE_NO
)
919 delDisplay
.spath
= source
;
920 delDisplay
.file
= FIB
->fib_FileName
;
922 delDisplay
.filelen
= FIB
->fib_Size
;
923 if (dmode
!= DELMODE_ALL
) dmode
= CallHook(delHook
, (Object
*) &delDisplay
, NULL
);
924 if ((dmode
== DELMODE_ALL
) || (dmode
== DELMODE_DELETE
))
927 info
= GetFileInfo(FIB
->fib_FileName
);
929 if ((info
& (FILEINFO_PROTECTED
|FILEINFO_WRITE
)) != 0)
931 if (pmode
!= DELMODE_NONE
)
934 (pmode
== DELMODE_ASK
) || (pmode
== DELMODE_DELETE
) ||
935 (pmode
== DELMODE_ALL
) || (pmode
== DELMODE_NO
)
938 delDisplay
.spath
= source
;
939 delDisplay
.file
= FIB
->fib_FileName
;
941 delDisplay
.filelen
= 0;
942 if (pmode
!= DELMODE_ALL
) pmode
= CallHook(delHook
, (Object
*) &delDisplay
, NULL
);
943 if ((pmode
== DELMODE_ALL
) || (pmode
== DELMODE_DELETE
))
946 SetProtection(FIB
->fib_FileName
, 0);
951 else unprotect
= TRUE
;
955 if (FIB
->fib_FileName
)
957 len
= strlen(FIB
->fib_FileName
);
961 fe
= AllocPooled(pool
, sizeof(struct FileEntry
) + len
);
964 strcpy(fe
->name
, FIB
->fib_FileName
);
988 if (DosError
!=ERROR_NO_MORE_ENTRIES
) Success
=TRUE
;
991 while (Success
&& !quit
);
996 len
= strlen(fef
->name
);
999 deleteFile(fef
->name
);
1002 FreePooled(pool
, fef
, sizeof(struct FileEntry
) + len
);
1009 FreeDosObject (DOS_FIB
,(APTR
) FIB2
);
1011 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
1017 BOOL
CopyContent(APTR p
, char *s
, char *d
, BOOL makeparentdir
, ULONG flags
, struct Hook
*displayHook
, struct Hook
*delHook
, APTR userdata
)
1020 struct FileInfoBlock
*FIB
;
1021 struct dCopyStruct display
;
1022 struct dCopyStruct delDisplay
;
1023 char *destname
, *dest
, *path
, *comment
, *dpath
, *infoname
, *destinfo
;
1024 LONG len
, Success2
, prot
;
1027 BOOL created
= FALSE
;
1030 BOOL deletesrc
, unprotectsrc
;
1032 UWORD dmode
= DELMODE_ASK
;
1033 UWORD pmode
= DELMODE_ASK
;
1034 UWORD omode
= DELMODE_ASK
;
1038 pool
= CreatePool(MEMF_CLEAR
|MEMF_ANY
, POOLSIZE
, POOLSIZE
);
1042 if (pool
== NULL
) return FALSE
;
1044 infoname
= AllocPooled(pool
, strlen(s
)+6);
1045 display
.userdata
= userdata
;
1046 delDisplay
.userdata
= userdata
;
1050 strncpy (infoname
, s
, strlen(s
));
1051 strcat(infoname
,".info");
1054 if (d
) destinfo
= AllocPooled(pool
, strlen(d
)+6); else destinfo
= NULL
;
1058 strncpy (destinfo
, d
, strlen(d
));
1059 strcat(destinfo
,".info");
1062 destname
= FilePart(s
);
1064 info
= GetFileInfo(s
);
1068 freeString(pool
, infoname
);
1069 freeString(pool
, destinfo
);
1070 if (p
== NULL
) DeletePool(pool
);
1074 if ((info
& FILEINFO_DIR
) != 0) dir
= TRUE
; else dir
= FALSE
;
1078 if ((flags
& ACTION_COPY
) !=0 ) dest
= allocString(pool
, d
);
1080 if (makeparentdir
&& dir
&& dest
)
1084 if (strlen(destname
)>0)
1086 freeString(pool
, dest
);
1088 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
1091 dest
= combinePath(pool
, d
, destname
);
1094 nLock
= Lock(dest
, ACCESS_READ
);
1097 Success2
= Examine(nLock
,FIB
);
1098 if (Success2
) if (FIB
->fib_DirEntryType
>0) created
= TRUE
;
1103 nDir
= CreateDir(dest
);
1108 prot
= GetProtectionInfo(s
);
1109 comment
= GetCommentInfo(pool
, s
);
1110 if (comment
) SetComment(dest
, comment
);
1111 SetProtection(dest
, prot
);
1112 freeString(pool
, comment
);
1117 freeString(pool
, dest
);
1122 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
1131 unprotectsrc
= TRUE
;
1132 if (delHook
&& ((flags
& ACTION_DELETE
) != 0) && ((makeparentdir
&& dir
) || !dir
))
1136 delDisplay
.spath
= s
;
1137 delDisplay
.file
= NULL
;
1141 path
= allocPath(pool
, s
);
1142 delDisplay
.spath
= path
;
1143 delDisplay
.file
= FilePart(s
);
1145 delDisplay
.type
= 0;
1147 dmode
= CallHook(delHook
, (Object
*) &delDisplay
, NULL
);
1148 if ((dmode
== DELMODE_ALL
) || (dmode
== DELMODE_DELETE
))
1151 if ((info
& (FILEINFO_PROTECTED
|FILEINFO_WRITE
)) != 0)
1153 delDisplay
.type
= 1;
1154 unprotectsrc
= FALSE
;
1155 pmode
= CallHook(delHook
, (Object
*) &delDisplay
, NULL
);
1156 if ((pmode
== DELMODE_ALL
) || (pmode
== DELMODE_DELETE
))
1158 SetProtection(s
, 0);
1159 if (infoname
) SetProtection(infoname
, 0);
1160 unprotectsrc
= TRUE
;
1168 if (delHook
&& !dir
)
1170 dpath
= combinePath(pool
, d
, FilePart(s
));
1173 info
= GetFileInfo(dpath
);
1176 if (delHook
&& (omode
!= DELMODE_NONE
))
1179 (omode
== DELMODE_ASK
) || (omode
== DELMODE_DELETE
) ||
1180 (omode
== DELMODE_ALL
) || (omode
== DELMODE_NO
)
1183 delDisplay
.spath
= d
;
1184 delDisplay
.file
= FilePart(s
);
1185 delDisplay
.type
= 2;
1186 if (omode
!= DELMODE_ALL
) omode
= CallHook(delHook
, (Object
*) &delDisplay
, NULL
);
1187 if ((omode
== DELMODE_ALL
) || (omode
== DELMODE_DELETE
))
1189 if (((info
& (FILEINFO_PROTECTED
|FILEINFO_WRITE
)) != 0) && (pmode
!= DELMODE_NONE
))
1192 (pmode
== DELMODE_ASK
) || (pmode
== DELMODE_DELETE
) ||
1193 (pmode
== DELMODE_ALL
) || (pmode
== DELMODE_NO
)
1196 delDisplay
.spath
= d
;
1197 delDisplay
.file
= FilePart(s
);
1198 delDisplay
.type
= 1;
1199 if (pmode
!= DELMODE_ALL
) pmode
= CallHook(delHook
, (Object
*) &delDisplay
, NULL
);
1200 if ((pmode
== DELMODE_ALL
) || (pmode
== DELMODE_DELETE
))
1202 SetProtection(dpath
, 0);
1211 freeString(pool
, dpath
);
1213 freeString(pool
, path
);
1218 if (dest
|| ((flags
& ACTION_DELETE
) != 0))
1221 ((dmode
== DELMODE_NONE
) || (dmode
== DELMODE_NO
)) &&
1222 (flags
& (ACTION_DELETE
|ACTION_COPY
)) == ACTION_DELETE
1230 pool
, flags
, s
, dest
, FALSE
, dmode
, pmode
, omode
, displayHook
, delHook
, userdata
1238 if (flags
== ACTION_DELETE
) back
= FALSE
;
1241 STRPTR path
= allocPath(pool
, s
);
1242 display
.file
= FilePart(s
);
1243 display
.filelen
= 0;
1244 display
.totallen
= 0;
1247 if (path
) display
.spath
= path
; else display
.spath
= s
;
1249 display
.flags
= (flags
&= ~ACTION_UPDATE
);
1250 if (displayHook
) CallHook(displayHook
, (Object
*) &display
, NULL
);
1251 back
= copyFile(pool
, s
, d
, NULL
, displayHook
, &display
);
1252 if (path
) freeString(pool
, path
);
1256 if (!back
&& destinfo
&& infoname
)
1258 SetProtection(destinfo
, 0);
1259 copyFile(pool
, infoname
, d
, NULL
, NULL
, NULL
);
1262 if (!back
&& delHook
&& (dmode
!= DELMODE_NONE
) && ((flags
& ACTION_DELETE
) !=0))
1264 if (unprotectsrc
&& deletesrc
)
1267 if (infoname
) deleteFile(infoname
);
1271 freeString(pool
, infoname
);
1272 freeString(pool
, destinfo
);
1273 freeString(pool
, dest
);