2 Copyright © 2007-2013, The AROS Development Team. All rights reserved.
6 #include "filesystems.h"
8 struct TagItem DummyTags
[] = { {TAG_DONE
, 0}};
10 /* define some nonglobal data that can be used by the display hook */
13 static void strcrem(char *s
, char *d
, char c
)
16 if (*s
!= c
) *d
++= *s
;
24 WORD
AskChoiceNew(const char *title
, const char *strg
, const char *gadgets
, UWORD sel
, BOOL centered
)
28 Object
*button
, *bObject
, *selObject
;
33 char Buffer
[64], Buffer1
[64];
37 app
= MUI_NewObject(MUIC_Application
,
39 MUIA_Application_Title
, (IPTR
)"Requester",
40 MUIA_Application_Base
, (IPTR
)"WANDERER_REQ",
42 SubWindow
, (IPTR
)(win
= MUI_NewObject(MUIC_Window
,
43 MUIA_Window_Title
, title
,
44 MUIA_Window_Activate
, TRUE
,
45 MUIA_Window_DepthGadget
, TRUE
,
46 MUIA_Window_SizeGadget
, FALSE
,
47 MUIA_Window_AppWindow
, FALSE
,
48 MUIA_Window_CloseGadget
, FALSE
,
49 MUIA_Window_Borderless
, FALSE
,
50 MUIA_Window_TopEdge
, MUIV_Window_TopEdge_Moused
,
51 MUIA_Window_LeftEdge
, MUIV_Window_LeftEdge_Moused
,
53 WindowContents
, (IPTR
)MUI_NewObject(MUIC_Group
,
54 Child
, (IPTR
)MUI_NewObject(MUIC_Text
,
59 MUIA_InnerBottom
,(12),
60 MUIA_Background
, MUII_TextBack
,
61 MUIA_Text_PreParse
, (IPTR
)"\33c",
62 MUIA_Text_Contents
, (IPTR
)strg
,
64 Child
, (IPTR
)(bObject
= MUI_NewObject(MUIC_Group
,MUIA_Group_Horiz
, TRUE
,TAG_DONE
)),
78 old
= SplitName(gadgets
, '|', Buffer
, old
, sizeof(Buffer
));
79 if (old
== -1) back
= 10;
80 strcrem(Buffer
, Buffer1
, '_');
81 button
= SimpleButton(Buffer1
);
84 if ((back
-10) == sel
) selObject
= button
;
85 set(button
, MUIA_CycleChain
, 1);
86 DoMethod(bObject
, MUIM_Group_InitChange
);
87 DoMethod(bObject
, OM_ADDMEMBER
, button
);
88 DoMethod(bObject
, MUIM_Group_ExitChange
);
89 DoMethod(button
,MUIM_Notify
,MUIA_Pressed
, FALSE
, app
,2,MUIM_Application_ReturnID
,back
);
98 set (win
, MUIA_Window_TopEdge
, MUIV_Window_TopEdge_Centered
);
99 set (win
, MUIA_Window_LeftEdge
, MUIV_Window_LeftEdge_Centered
);
101 if (selObject
) set(win
, MUIA_Window_ActiveObject
, selObject
);
102 set(win
,MUIA_Window_Open
,TRUE
);
106 id
= DoMethod(app
,MUIM_Application_Input
,&signals
);
110 case MUIV_Application_ReturnID_Quit
:
150 if (running
&& signals
) Wait(signals
);
152 set(win
,MUIA_Window_Open
,FALSE
);
153 MUI_DisposeObject(app
);
160 WORD
AskChoice(const char *title
, const char *strg
, const char *gadgets
, UWORD sel
)
162 return AskChoiceNew(title
, strg
, gadgets
, sel
, FALSE
);
166 ///AskChoiceCentered()
167 WORD
AskChoiceCentered(const char *title
, const char *strg
, const char *gadgets
, UWORD sel
)
169 return AskChoiceNew(title
, strg
, gadgets
, sel
, TRUE
);
174 static char *combinePath(APTR pool
, char *path
, char *file
)
178 if ((path
== NULL
) || (file
== NULL
)) return NULL
;
179 if (strlen(path
) == 0) return NULL
;
180 if (strlen(file
) == 0) return NULL
;
182 l
= strlen(path
) + strlen(file
) + 1;
183 if (path
[strlen(path
)-1] != '/') l
++;
185 if (pool
== NULL
) out
= AllocVec(l
, MEMF_CLEAR
);
186 else out
= AllocVecPooled(pool
, l
);
191 AddPart(out
, file
, l
);
198 static char *allocPath(APTR pool
, char *str
)
209 for (l
=0; s0
!= s1
; s0
++,l
++);
211 s
= AllocVecPooled(pool
, l
+1);
212 if (s
) strncpy(s
, str
, l
);
219 void freeString(APTR pool
, char *str
)
226 FreeVecPooled(pool
, str
);
233 ** allocates memory for a string and copies them to the new buffer
235 ** inputs: str source string
236 ** return: char pointer to string or NULL
239 static char *allocString(APTR pool
, char *str
)
244 if (str
== NULL
) return NULL
;
249 b
= (char*) AllocVec(l
+1, MEMF_CLEAR
);
250 else b
= (char*) AllocVecPooled(pool
, l
+1);
252 if (b
&& (l
>0)) strncpy (b
, str
, l
);
258 char *CombineString(char *format
, ...)
262 char *s
, *s1
, *str
, *p
;
267 while ((s
= strstr(s
,"%s")) != NULL
) {cnt
++; s
++; }
271 len
= strlen(format
) - 2*cnt
;
272 va_start(ap
, format
);
277 p
= va_arg(ap
, char *);
284 back
= AllocVec(len
, MEMF_CLEAR
);
289 va_start(ap
, format
);
290 while ((s1
= strstr(s
, "%s")) != NULL
)
292 p
= va_arg(ap
, char *);
294 strncpy(str
, s
, len
);
297 strncpy(str
, p
, strlen(p
));
300 if (s
) strncpy(str
, s
, strlen(s
));
310 static LONG
GetFileInfo(char *name
)
312 struct FileInfoBlock
*FIB
;
318 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
321 nLock
= Lock(name
, ACCESS_READ
);
324 Success2
= Examine(nLock
,FIB
);
328 if (FIB
->fib_DirEntryType
>0) info
|= FILEINFO_DIR
;
329 if ((FIB
->fib_Protection
& FIBF_DELETE
) != 0) info
|= FILEINFO_PROTECTED
;
330 if ((FIB
->fib_Protection
& FIBF_WRITE
) != 0) info
|= FILEINFO_WRITE
;
334 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
340 ///GetProtectionInfo()
341 static LONG
GetProtectionInfo(char *name
)
343 struct FileInfoBlock
*FIB
;
349 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
352 nLock
= Lock(name
, ACCESS_READ
);
355 Success2
= Examine(nLock
,FIB
);
358 info
= FIB
->fib_Protection
;
362 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
369 static char *GetCommentInfo(APTR pool
, char *name
)
371 struct FileInfoBlock
*FIB
;
378 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
381 nLock
= Lock(name
, ACCESS_READ
);
384 Success2
= Examine(nLock
,FIB
);
387 info
= allocString(pool
, (char*) &FIB
->fib_Comment
);
391 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
398 static BOOL
deleteFile(char *file
)
406 static BOOL
copyFile(APTR pool
, char *file
, char *destpath
,
407 struct FileInfoBlock
*fileinfo
, struct Hook
*displayHook
,
408 struct dCopyStruct
*display
)
410 struct FileInfoBlock
*fib
;
413 LONG bufferlen
= COPYLEN
;
420 if (display
!= NULL
) display
->totallen
= 0;
421 if (display
!= NULL
) display
->actlen
= 0;
424 filelen
= fileinfo
->fib_Size
;
425 if (fileinfo
->fib_Size
<= COPYLEN
) bufferlen
= fileinfo
->fib_Size
;
426 if (bufferlen
< 8192) bufferlen
= 8192;
431 fib
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
434 nLock
= Lock(file
, ACCESS_READ
);
437 if (Examine(nLock
,fib
) == 0)
443 filelen
= fib
->fib_Size
;
444 if (fib
->fib_Size
<= COPYLEN
) bufferlen
= fib
->fib_Size
;
445 if (bufferlen
< 8192) bufferlen
= 8192;
453 to
= combinePath(pool
, destpath
, FilePart(file
));
456 buffer
= AllocVecPooled(pool
, bufferlen
);
459 in
= Open(file
, MODE_OLDFILE
);
462 out
= Open(to
, MODE_NEWFILE
);
466 unsigned int difftime
= clock();
469 clen
= Read(in
, buffer
, bufferlen
);
470 if ((clen
!=0) && (clen
!= -1))
472 wlen
= Write(out
, buffer
,clen
);
475 display
->difftime
= clock() - difftime
;
476 if (display
->difftime
< 1) display
->difftime
= 1;
477 display
->actlen
= clen
;
478 display
->totallen
+= clen
;
479 display
->filelen
= filelen
;
482 display
->flags
|= ACTION_UPDATE
;
483 stop
= CallHook(displayHook
, (Object
*) display
, NULL
);
487 if (clen
!= wlen
) clen
= 0;
490 while ((clen
!=0) && (clen
!= -1) && !stop
);
498 SetComment(to
, fib
->fib_Comment
);
499 SetProtection(to
, fib
->fib_Protection
);
504 FreeVecPooled(pool
, buffer
);
506 freeString(pool
, to
);
508 if (fileinfo
== NULL
) FreeDosObject(DOS_FIB
,(APTR
) fib
);
514 static VOID
handleUnprotect(LONG info
, char * spath
, char * file
, char * target
, struct Hook
* askHook
, WORD
* pmode
, BOOL
* unprotect
)
516 struct dCopyStruct askDisplay
;
518 if ((info
& (FILEINFO_PROTECTED
|FILEINFO_WRITE
)) != 0)
520 if (*pmode
!= OPMODE_NONE
)
523 (*pmode
== OPMODE_ASK
) || (*pmode
== OPMODE_YES
) ||
524 (*pmode
== OPMODE_ALL
) || (*pmode
== OPMODE_NO
)
527 askDisplay
.spath
= spath
;
528 askDisplay
.file
= file
;
530 askDisplay
.filelen
= 0;
531 if (*pmode
!= OPMODE_ALL
) *pmode
= CallHook(askHook
, (Object
*) &askDisplay
, NULL
);
532 if ((*pmode
== OPMODE_ALL
) || (*pmode
== OPMODE_YES
))
534 SetProtection(target
, 0);
540 else *unprotect
= TRUE
;
543 #define dmode (opModes->deletemode)
544 #define pmode (opModes->protectmode)
545 #define omode (opModes->overwritemode)
547 static BOOL
actionDir(APTR pool
, ULONG flags
, char *source
, char *dest
,
548 BOOL quit
, struct Hook
*dHook
, struct OpModes
* opModes
, APTR userdata
)
550 struct FileInfoBlock
*FIB
, *FIB2
;
551 struct dCopyStruct display
;
552 struct dCopyStruct askDisplay
;
553 struct FileEntry
*fe
, *fef
, *fel
;
555 BPTR NewLock
, cDir
, nDir
, nLock
;
556 ULONG Success
, Success1
, Success2
, DosError
, len
;
557 char *dname
, *comment
, *dpath
;
558 BOOL del
, created
, unprotect
, failure
;
562 if (quit
) return TRUE
;
566 display
.userdata
= userdata
;
567 askDisplay
.userdata
= userdata
;
572 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
575 FIB2
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
578 NewLock
= Lock(source
,ACCESS_READ
);
581 cDir
= CurrentDir(NewLock
);
583 Success1
=Examine(NewLock
,FIB
);
588 /* For each entry in directory ... */
589 Success
=ExNext(NewLock
,FIB
);
591 /* If OPMODE_NONE, stop all actions */
592 if ((flags
& (ACTION_DELETE
| ACTION_COPY
)) == ACTION_DELETE
)
594 if (dmode
== OPMODE_NONE
) Success
= FALSE
;
597 if (Success
&& Success1
)
599 if (FIB
->fib_DirEntryType
>0)
601 /* The entry is a directory */
604 /* If copying, check if the destination directory exists and create if needed */
605 if (((flags
& ACTION_COPY
) != 0) && dest
)
607 dname
= combinePath(pool
, dest
, FIB
->fib_FileName
);
611 nLock
= Lock(dname
, ACCESS_READ
);
614 Success2
= Examine(nLock
,FIB2
);
615 if (Success2
) if (FIB2
->fib_DirEntryType
>0) created
= TRUE
;
620 nDir
= CreateDir(dname
);
623 prot
= GetProtectionInfo(FIB
->fib_FileName
);
624 comment
= GetCommentInfo(pool
, FIB
->fib_FileName
);
625 if (comment
) SetComment(dname
, comment
);
626 SetProtection(dname
, prot
);
627 freeString(pool
, comment
);
638 /* If deleting, ask for confirmation and ask to unprotect */
639 if (opModes
&& (dmode
!= OPMODE_NONE
) && ((flags
& ACTION_DELETE
) != 0))
641 if ((dmode
== OPMODE_ASK
) || (dmode
== OPMODE_YES
) || (dmode
== OPMODE_ALL
) || (dmode
== OPMODE_NO
))
643 askDisplay
.spath
= FIB
->fib_FileName
;
644 askDisplay
.file
= NULL
;
646 askDisplay
.filelen
= FIB
->fib_Size
;
647 if (dmode
!= OPMODE_ALL
) dmode
= CallHook(opModes
->askhook
, (Object
*) &askDisplay
, NULL
);
648 if ((dmode
== OPMODE_ALL
) || (dmode
== OPMODE_YES
))
652 info
= GetFileInfo(FIB
->fib_FileName
);
654 handleUnprotect(info
, FIB
->fib_FileName
, NULL
, FIB
->fib_FileName
, opModes
->askhook
, &pmode
, &unprotect
);
664 /* If directory was created or we are deleting, trawl deeper and repeat actions */
665 if (created
|| ((flags
& ACTION_DELETE
) !=0))
667 if (((dmode
== OPMODE_NO
) || (dmode
== OPMODE_NONE
)) && (flags
== ACTION_DELETE
))
673 quit
= actionDir(pool
, flags
, FIB
->fib_FileName
, dname
, quit
, dHook
, opModes
, userdata
);
677 /* If deleting and all actions succeeded in deeper directory, add the directory to "to be deleted" list */
678 if (!quit
&& del
&& unprotect
)
680 if (FIB
->fib_FileName
)
682 len
= strlen(FIB
->fib_FileName
);
686 fe
= AllocVecPooled(pool
, sizeof(struct FileEntry
) + len
);
689 strcpy(fe
->name
, FIB
->fib_FileName
);
704 freeString(pool
, dname
);
708 /* The entry is a file */
711 display
.file
= FIB
->fib_FileName
;
712 display
.filelen
= FIB
->fib_Size
;
713 display
.spath
= source
;
714 display
.dpath
= dest
;
715 display
.flags
= (flags
&= ~ACTION_UPDATE
);
716 display
.totallen
= 0;
719 quit
= CallHook(dHook
, (Object
*) &display
, NULL
);
724 /* If copying, ask for overwrite destinatin and ask for unprotect destination */
725 if (((flags
& ACTION_COPY
) != 0) && dest
)
727 dpath
= combinePath(pool
, dest
, FIB
->fib_FileName
);
730 info
= GetFileInfo(dpath
);
734 if (opModes
&& (omode
!= OPMODE_NONE
))
737 (omode
== OPMODE_ASK
) || (omode
== OPMODE_YES
) ||
738 (omode
== OPMODE_ALL
) || (omode
== OPMODE_NO
)
741 askDisplay
.spath
= dest
;
742 askDisplay
.file
= FIB
->fib_FileName
;
744 askDisplay
.filelen
= 0;
745 if (omode
!= OPMODE_ALL
) omode
= CallHook(opModes
->askhook
, (Object
*) &askDisplay
, NULL
);
746 if ((omode
== OPMODE_ALL
) || (omode
== OPMODE_YES
))
748 handleUnprotect(info
, dest
, FIB
->fib_FileName
, dpath
, opModes
->askhook
, &pmode
, &overwrite
);
753 freeString(pool
, dpath
);
759 if (!quit
&& ((flags
& ACTION_COPY
) !=0) && overwrite
)
761 display
.flags
= (flags
&= ~ACTION_UPDATE
);
762 failure
= copyFile(pool
, FIB
->fib_FileName
, dest
, FIB
, dHook
, &display
);
765 /* If failed, ask if process should continue */
766 if (failure
&& !quit
)
770 askDisplay
.spath
= source
;
771 askDisplay
.file
= FIB
->fib_FileName
;
773 askDisplay
.filelen
= 0;
774 if (CallHook(opModes
->askhook
, (Object
*) &askDisplay
, NULL
) == ACCESS_SKIP
)
775 quit
= FALSE
; else quit
= TRUE
;
780 /* If deleting ask for confirmation and ask to unprotect */
781 if (!quit
&& opModes
&& (dmode
!= OPMODE_NONE
) && ((flags
& ACTION_DELETE
) !=0))
784 (dmode
== OPMODE_ASK
) || (dmode
== OPMODE_YES
) ||
785 (dmode
== OPMODE_ALL
) || (dmode
== OPMODE_NO
)
788 askDisplay
.spath
= source
;
789 askDisplay
.file
= FIB
->fib_FileName
;
791 askDisplay
.filelen
= FIB
->fib_Size
;
792 if (dmode
!= OPMODE_ALL
) dmode
= CallHook(opModes
->askhook
, (Object
*) &askDisplay
, NULL
);
793 if ((dmode
== OPMODE_ALL
) || (dmode
== OPMODE_YES
))
796 info
= GetFileInfo(FIB
->fib_FileName
);
799 handleUnprotect(info
, source
, FIB
->fib_FileName
, FIB
->fib_FileName
, opModes
->askhook
, &pmode
, &unprotect
);
801 /* If file ready to be deleted, add it to "to be deleted" list */
804 if (FIB
->fib_FileName
)
806 len
= strlen(FIB
->fib_FileName
);
810 fe
= AllocVecPooled(pool
, sizeof(struct FileEntry
) + len
);
813 strcpy(fe
->name
, FIB
->fib_FileName
);
837 /* Is this the end of entries in directory ? */
838 if (DosError
!=ERROR_NO_MORE_ENTRIES
) Success
=TRUE
;
841 while (Success
&& !quit
);
844 /* Delete all directories and files which were put on the "to be deleted" list */
847 len
= strlen(fef
->name
);
850 deleteFile(fef
->name
);
853 FreeVecPooled(pool
, fef
);
860 FreeDosObject (DOS_FIB
,(APTR
) FIB2
);
862 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
873 BOOL
CopyContent(APTR p
, char *s
, char *d
, BOOL makeparentdir
, ULONG flags
, struct Hook
*displayHook
, struct OpModes
*opModes
, APTR userdata
)
876 struct FileInfoBlock
*FIB
;
877 struct dCopyStruct display
;
878 struct dCopyStruct askDisplay
;
879 char *destname
, *dest
, *path
, *comment
, *dpath
, *infoname
, *destinfo
;
884 BOOL created
= FALSE
;
887 BOOL deletesrc
, unprotectsrc
;
892 pool
= CreatePool(MEMF_CLEAR
|MEMF_ANY
, POOLSIZE
, POOLSIZE
);
896 if (pool
== NULL
) return FALSE
;
898 infoname
= AllocVecPooled(pool
, strlen(s
)+6);
899 display
.userdata
= userdata
;
900 askDisplay
.userdata
= userdata
;
904 strncpy (infoname
, s
, strlen(s
));
905 strcat(infoname
,".info");
908 if (d
) destinfo
= AllocVecPooled(pool
, strlen(d
)+6); else destinfo
= NULL
;
912 strncpy (destinfo
, d
, strlen(d
));
913 strcat(destinfo
,".info");
916 destname
= FilePart(s
);
918 info
= GetFileInfo(s
);
922 freeString(pool
, infoname
);
923 freeString(pool
, destinfo
);
924 if (p
== NULL
) DeletePool(pool
);
928 if ((info
& FILEINFO_DIR
) != 0) dir
= TRUE
; else dir
= FALSE
;
932 if ((flags
& ACTION_COPY
) !=0 ) dest
= allocString(pool
, d
);
934 /* If copying a directory, create target directory */
935 if (makeparentdir
&& dir
&& dest
)
939 if (strlen(destname
)>0)
941 freeString(pool
, dest
);
943 FIB
= (struct FileInfoBlock
*) AllocDosObject(DOS_FIB
,DummyTags
);
946 dest
= combinePath(pool
, d
, destname
);
949 nLock
= Lock(dest
, ACCESS_READ
);
952 Success2
= Examine(nLock
,FIB
);
953 if (Success2
) if (FIB
->fib_DirEntryType
>0) created
= TRUE
;
958 nDir
= CreateDir(dest
);
963 prot
= GetProtectionInfo(s
);
964 comment
= GetCommentInfo(pool
, s
);
965 if (comment
) SetComment(dest
, comment
);
966 SetProtection(dest
, prot
);
967 freeString(pool
, comment
);
972 freeString(pool
, dest
);
977 FreeDosObject (DOS_FIB
,(APTR
) FIB
);
987 /* If deleting ask for confirmation, ask to unprotect */
988 if (opModes
&& (opModes
->deletemode
!= OPMODE_NONE
) && ((flags
& ACTION_DELETE
) != 0) && ((makeparentdir
&& dir
) || !dir
))
992 askDisplay
.spath
= s
;
993 askDisplay
.file
= NULL
;
997 path
= allocPath(pool
, s
);
998 askDisplay
.spath
= path
;
999 askDisplay
.file
= FilePart(s
);
1001 askDisplay
.type
= 0;
1003 if (opModes
->deletemode
!= OPMODE_ALL
) opModes
->deletemode
= CallHook(opModes
->askhook
, (Object
*) &askDisplay
, NULL
);
1004 if ((opModes
->deletemode
== OPMODE_ALL
) || (opModes
->deletemode
== OPMODE_YES
))
1007 if ((info
& (FILEINFO_PROTECTED
|FILEINFO_WRITE
)) != 0)
1009 askDisplay
.type
= 1;
1010 unprotectsrc
= FALSE
;
1011 opModes
->protectmode
= CallHook(opModes
->askhook
, (Object
*) &askDisplay
, NULL
);
1012 if ((opModes
->protectmode
== OPMODE_ALL
) || (opModes
->protectmode
== OPMODE_YES
))
1014 SetProtection(s
, 0);
1015 if (infoname
) SetProtection(infoname
, 0);
1016 unprotectsrc
= TRUE
;
1022 /* If copying ask to overwrite, ask to unprotect */
1025 if (opModes
&& !dir
)
1027 dpath
= combinePath(pool
, d
, FilePart(s
));
1030 info
= GetFileInfo(dpath
);
1033 if (opModes
&& (opModes
->overwritemode
!= OPMODE_NONE
))
1036 (opModes
->overwritemode
== OPMODE_ASK
) || (opModes
->overwritemode
== OPMODE_YES
) ||
1037 (opModes
->overwritemode
== OPMODE_ALL
) || (opModes
->overwritemode
== OPMODE_NO
)
1040 askDisplay
.spath
= d
;
1041 askDisplay
.file
= FilePart(s
);
1042 askDisplay
.type
= 2;
1043 if (opModes
->overwritemode
!= OPMODE_ALL
) opModes
->overwritemode
= CallHook(opModes
->askhook
, (Object
*) &askDisplay
, NULL
);
1044 if ((opModes
->overwritemode
== OPMODE_ALL
) || (opModes
->overwritemode
== OPMODE_YES
))
1046 if (((info
& (FILEINFO_PROTECTED
|FILEINFO_WRITE
)) != 0) && (opModes
->protectmode
!= OPMODE_NONE
))
1049 (opModes
->protectmode
== OPMODE_ASK
) || (opModes
->protectmode
== OPMODE_YES
) ||
1050 (opModes
->protectmode
== OPMODE_ALL
) || (opModes
->protectmode
== OPMODE_NO
)
1053 askDisplay
.spath
= d
;
1054 askDisplay
.file
= FilePart(s
);
1055 askDisplay
.type
= 1;
1056 if (opModes
->protectmode
!= OPMODE_ALL
) opModes
->protectmode
= CallHook(opModes
->askhook
, (Object
*) &askDisplay
, NULL
);
1057 if ((opModes
->protectmode
== OPMODE_ALL
) || (opModes
->protectmode
== OPMODE_YES
))
1059 SetProtection(dpath
, 0);
1067 freeString(pool
, dpath
);
1071 freeString(pool
, path
);
1075 if (dest
|| ((flags
& ACTION_DELETE
) != 0))
1078 ((opModes
->deletemode
== OPMODE_NONE
) || (opModes
->deletemode
== OPMODE_NO
)) &&
1079 (flags
& (ACTION_DELETE
|ACTION_COPY
)) == ACTION_DELETE
1086 back
= actionDir(pool
, flags
, s
, dest
, FALSE
, displayHook
, opModes
, userdata
);
1093 if (flags
== ACTION_DELETE
) back
= FALSE
;
1096 STRPTR path
= allocPath(pool
, s
);
1097 display
.file
= FilePart(s
);
1098 display
.filelen
= 0;
1099 display
.totallen
= 0;
1102 if (path
) display
.spath
= path
; else display
.spath
= s
;
1104 display
.flags
= (flags
&= ~ACTION_UPDATE
);
1105 if (displayHook
) CallHook(displayHook
, (Object
*) &display
, NULL
);
1106 back
= copyFile(pool
, s
, d
, NULL
, displayHook
, &display
);
1107 freeString(pool
, path
);
1111 if (!back
&& destinfo
&& infoname
)
1113 SetProtection(destinfo
, 0);
1114 copyFile(pool
, infoname
, d
, NULL
, NULL
, NULL
);
1117 if (!back
&& opModes
&& (opModes
->deletemode
!= OPMODE_NONE
) && ((flags
& ACTION_DELETE
) !=0))
1119 if (unprotectsrc
&& deletesrc
)
1122 if (infoname
) deleteFile(infoname
);
1126 freeString(pool
, infoname
);
1127 freeString(pool
, destinfo
);
1128 freeString(pool
, dest
);