home *** CD-ROM | disk | FTP | other *** search
- // FileSelect.c
- // 06 Dec 1996 11:24:53
-
- #ifndef BACKUP_INCLUDE
- #include "IncludeAll.c"
- #endif
- #include "Backup.h"
- #include "FileSelect.h"
- #include "Backup_proto.h"
- #include "BackupStrings.h"
-
- #define d(x) ;
- #define d2(x) x;
-
- #define DOSLIST_FLAGS (LDF_VOLUMES|LDF_ASSIGNS|LDF_DEVICES|LDF_READ)
-
-
- #define EXALL_BUFFSIZE 65536l // Buffergröße für ExAll()
-
-
- // Abmessungen des FS-Window
- #define DFLT_LEFT 34
- #define DFLT_TOP 31
- #define DFLT_WIDTH (442-13)
- #define DFLT_HEIGHT 336
-
- #define MAX_FSWIDTH 531
- #define MIN_FSHEIGHT 200
- #define MAX_FSHEIGHT (~0)
-
-
- #define FSDIR_STEP 5
-
- #define DEFAULTLISTSIZE 512 // default-Größe der File-Liste
-
-
- struct FSNewEntry
- {
- struct Node fsn_Node;
- struct ALVRecordInsert fsn_Insert;
- };
-
-
- static UWORD ComputeX( UWORD value );
- static UWORD ComputeY( UWORD value );
- static short inROM(APTR addr);
- static void FSRender( void );
- static void InitFS(void);
- static BOOL BeginFileSelect(struct BackupOptions *Opts, int *FSResult);
- static void EndFileSelect(void);
- static int HandleFSMsg(void);
- static int FS_IDCMPHandler(struct IntuiMessage *msg, short *abortFSRead);
- static void __interrupt HandleFSGadgetCallback(struct Hook *hook, struct Gadget *Gad, ULONG *Code);
- static void HandleFSGadgetHelp(const struct Gadget *gad, USHORT code);
- static short HandleFSGadget(struct Gadget *gad, USHORT code, short *abortFSRead);
- static void ScrollFSWindow(USHORT Code, USHORT Qualifier);
- static BOOL HandleStrGadCode(USHORT code);
- static char *NormalizeName(const char *Name);
- static struct FSDir *GetFSDir(const char *DirName, struct FSDirEntry *Parent);
- static struct FSDir *ReadFSDir(const char *DirName, struct FSDir *Dir, struct FSDirEntry *Parent);
- static void InsertEntryList(struct List *EntryList, BOOL ClearOnly);
- static short BeginDir(const char *DirName, struct NextFileInfo *nfInfo);
- static void EndDir(struct NextFileInfo *nfInfo);
- static struct FSDirEntry *NextFSDirEntry(struct NextFileInfo *nfInfo);
- static enum FType GetFibType(long EntryType, const STRPTR Name, BPTR DirLock);
- static struct FSDirEntry *NewFSEntry(const char *Name, enum FType Typ);
- static void DestroyFSEntry(struct FSDirEntry **FSe);
- static struct FSDir *MakeFSDir(const char *DirName, struct BackupOptions *Options);
- static void RemoveFSDir(struct FSDir *Dir);
- static void ExtendFSDir(struct FSDir *dir);
- static void SetFSDirListSize(struct FSDir *dir, unsigned long NewSize);
- static void FindAndRedisplayDirEntry(struct FSDir *Dir, struct FSDirEntry *FSe,
- ULONG FirstColumn, ULONG LastColumn, enum RedisplayMode Changed);
- static void DisplayFSList(struct FSDir *Dir);
- static void SortFSList(struct FSDir *dir);
- static short DifferentType(const struct FSDirEntry *fs1, const struct FSDirEntry *fs2);
- static void FSSubDir(struct FSDirEntry *SubDirEntry);
- static void FSParentDir(void);
- static struct FSDir *GetVolumes(void);
- static void DuplicateOldEntry(struct FSDir *Dir, struct FSDir *OldDir,
- struct FSDirEntry *FSe);
- static void ReSortEntryList(struct FSDir *Dir);
- static char *GetFullPathName(BPTR FileLock);
- static struct FSDirEntry *FindFSEntry(const char *Name, struct FSDir *Dir);
- static void SelectDirEntry(struct FSDir *Dir, short n, BOOL Manual);
- static void DeselectDirEntry(struct FSDir *Dir, short n, BOOL Manual);
- static void SelectChildEntry(struct FSDir *Dir, struct FSDirEntry *FSe, short Level);
- static void InternalSelectEntry(struct FSDir *Dir, struct FSDirEntry *FSe,
- BOOL Select, BOOL Manual, short Level, BOOL Recursive);
- static char *FindParentName(char *DirName);
- static void SelectFSAttr(BOOL Select);
- static BOOL LookUpFSDir(char *ParentName, char *DirName);
- static struct FSDir *LookUpSubDir(char *ParentName, unsigned long *n);
- static struct FSDir *LookUpParentDir(const char *SubDirName, unsigned long *n);
- static void EmptyFSDir(struct FSDir *dir);
- static short SetFSHasSelects(struct FSDir *Dir);
- static BOOL isleap(short year);
- static void SetupBackupOpts(struct BackupOptions *NewOpts, const char *CmdFileName);
- static void DisplaySelectCount(void);
- static void EnableGOGadget(void);
- static short isFile(const struct FSDirEntry *FS);
- static void UseDiskObject(struct AppMessage *AppMsg);
- static void AddFSEntries(struct AppMessage *AppMsg);
- static BOOL isChildOf(const char *Parent, const char *Child);
- static size_t InsertFSe(struct FSDir *Dir, struct FSDirEntry *FSe);
- static BOOL isInWindow(struct Window *Win, short x, short y);
- static void GetPatternGadgetString(void);
- static ULONG __interrupt __saveds DisplayFileSizeHookFunc(struct Hook *HookPtr,
- struct FSDirEntry *Record, struct ALVDrawMsg *Msg );
- static ULONG __interrupt __saveds DisplayFileProtectionHookFunc(struct Hook *HookPtr,
- struct FSDirEntry *Record, struct ALVDrawMsg *Msg );
- static ULONG __interrupt __saveds ClickFileHookFunc(struct Hook *HookPtr,
- struct FSDirEntry *Record, struct ALVDrawMsg *Msg );
- static ULONG __interrupt __saveds DisplaySelectHookFunc(struct Hook *HookPtr,
- struct FSDirEntry *Record, struct ALVDrawMsg *Msg );
- static ULONG __interrupt __saveds SelectFileHookFunc(struct Hook *HookPtr,
- struct FSDirEntry *Record, struct ALVDrawMsg *Msg );
- static BOOL isInFileView(WORD MouseX, WORD MouseY);
- static void __interrupt DrawMarkerBox(struct RastPort *rp, short xMin, short xMax, short yMin, short yMax);
- static void __interrupt DrawSelectMarker(struct RastPort *rp, short x, short y, short Width,
- const struct FSDirEntry *Record, const struct ALVDrawMsg *Msg);
-
-
- // aus Backup.c
- extern struct TextFont *myFont, *ScreenFont;
- extern struct MsgPort *AppPort; // Msg Port für AppMessages
- extern struct DiskFlags __far *Disks; /* Laufwerks-Liste */
-
- // aus Backup_Window.c
- extern struct TextAttr DefaultFAttr;
- extern struct Library *AmigaGuideBase;
- extern struct Library *GadToolsBase;
- extern char BackupScreenTitle[80]; // Screen Title
- extern APTR vi; // VisualInfo
- extern struct DrawInfo *myDrawInfo;
- extern struct Screen *WBScreen;
-
- // aus CmdFile.c
- extern FILE *aktCmdFile; // fp für Kommandofile
- extern char __far CmdFileName[FMSIZE]; // Name des Kommandofile
-
- // aus FileSelectGadget.c
- extern struct TagItem MoreALVTags[];
- extern struct Image AssignImage;
- extern struct Image VolumeImage;
- extern struct Image DrawerImage;
-
- // aus Text.c
- extern struct Locale *myLocale;
-
-
- BOOL HelpActive = FALSE; // Online-Hilfe ist aktiv
- BOOL GadgetHelp = FALSE; // V39-GadgetHelp ist verfügbar
-
- struct Window *activeWindow; // das gerade aktive Backup-Window
-
- struct BackupOptions *BackupOpt = NULL; // Optionen während der Sicherung
-
- ULONG BackupHelpGroup; // Help Group
-
- static MINLIST(FSResourceList);
-
- static struct BInputHandler *FSInput = NULL;
-
- struct IBox FSWindowPos = { DFLT_LEFT, DFLT_TOP, DFLT_WIDTH, DFLT_HEIGHT };
- static struct IBox FSWindowLimits = { DFLT_WIDTH, MIN_FSHEIGHT, MAX_FSWIDTH, MAX_FSHEIGHT };
-
- static struct Gadget *FSGList = NULL;
- static struct Gadget *FSGadgets[FS_CNT];
- static UWORD OffX, OffY;
- static ULONG FontX, FontY;
-
- static struct GadgetShort *FSGadgetShort; // Tabelle für Tasten-Kürzel
-
- struct Window *MenuWin; // an diesem Window hängt das Menu
- struct Window *FSwin; // File Select Window
-
- static struct AppWindow *myAppWindow = NULL;
-
- static struct ScrollingWindow FileDisplayScr;
-
- static short InnerWidth, InnerHeight; // innere Abmessungen des Window
-
- static short MouseButtonDown; // 1, solange linke Maustaste innerhalb der File-Liste gedrückt bleibt
-
- static struct FSDir *aktFSDir = NULL;
-
- static int *globalFSResult = NULL; // hier wird beim ersten Füllen des FS-Windows ggf. ein eingabe()-Result abgelegt
- // zur Weiterverarbeitung in BeginGO()
-
- static struct NamePattern SelectPattern = { "#?", "", FALSE }; // zur Auswahl nach Namen
- static enum ArchiveSelect FSArchiveSelect = ARCSEL_ignore; // zur Auswahl nach Archiv-Bit
-
- static unsigned long MainFSDirLength = 0L;
-
- static unsigned long FSFileSelectCount = 0L; // Anzahl selektierte Files
- static unsigned long FSDirSelectCount = 0L; // Anzahl selektierte Directories
-
- static short GlobalFSStartCode = 0;
-
- static MINLIST(SelectRecordsList);
- static MINLIST(SubDirRecordsList);
-
-
- static struct Hook FSGadgetShortHook =
- {
- { NULL },
- HookEntry,
- (ULONG (*)()) HandleFSGadgetCallback,
- NULL, // wird (short *)
- };
-
- static struct Hook DisplayFileSizeHook =
- {
- { NULL },
- HookEntry,
- (ULONG (*)()) DisplayFileSizeHookFunc,
- NULL,
- };
-
- static struct Hook DisplayFileProtectionHook =
- {
- { NULL },
- HookEntry,
- (ULONG (*)()) DisplayFileProtectionHookFunc,
- NULL,
- };
-
- static struct Hook DisplaySelectHook =
- {
- { NULL },
- HookEntry,
- (ULONG (*)()) DisplaySelectHookFunc,
- NULL,
- };
-
- struct Hook ClickFileHook =
- {
- { NULL },
- HookEntry,
- (ULONG (*)()) ClickFileHookFunc,
- NULL,
- };
-
- struct Hook SelectFileHook =
- {
- { NULL },
- HookEntry,
- (ULONG (*)()) SelectFileHookFunc,
- NULL,
- };
-
-
- #define ALV_STDFLAGS 0l
-
- struct ALVColumn FileSelectColumns[] =
- {
- // SubDir-Select-Marker
- { NULL, ALVLT_StringPtr, { NULL, 0l, 0l }, ALVAH_HCenter, ALVAV_VCenter,
- ALVLT_User, ALVAH_HCenter, ALVAV_VCenter,
- (size_t) &DisplaySelectHook,
- 0, ALV_STDFLAGS,
- &FileSelectColumns[1] },
- // Icon
- { NULL, ALVLT_StringPtr, { NULL, 0l, 0l }, ALVAH_HCenter, ALVAV_VCenter,
- ALVLT_Image, ALVAH_HCenter, ALVAV_VCenter,
- offsetof(struct FSDirEntry, fse_Image),
- 0, ALV_STDFLAGS,
- &FileSelectColumns[2] },
- // Filename
- { NULL, ALVLT_StringPtr, { NULL, 0l, 0l }, ALVAH_HCenter, ALVAV_VCenter,
- ALVLT_String, ALVAH_Left, ALVAV_VCenter,
- offsetof(struct FSDirEntry, fse_Name),
- 0, ALV_STDFLAGS,
- &FileSelectColumns[3] },
- // Filegröße
- { NULL, ALVLT_String, { NULL, 0l, 0l }, ALVAH_HCenter, ALVAV_VCenter,
- ALVLT_UserString, ALVAH_Right, ALVAV_VCenter,
- (size_t) &DisplayFileSizeHook,
- 0, ALV_STDFLAGS,
- &FileSelectColumns[4] },
- // Protection
- { NULL, ALVLT_String, { NULL, 0l, 0l }, ALVAH_HCenter, ALVAV_VCenter,
- ALVLT_UserString, ALVAH_HCenter, ALVAV_VCenter,
- (size_t) &DisplayFileProtectionHook,
- 0, ALV_STDFLAGS,
- &FileSelectColumns[5] },
- // Datum
- { NULL, ALVLT_String, { NULL, 0l, 0l }, ALVAH_HCenter, ALVAV_VCenter,
- ALVLT_Date, ALVAH_Right, ALVAV_VCenter,
- offsetof(struct FSDirEntry, fse_Date),
- 0, ALV_STDFLAGS,
- &FileSelectColumns[6] },
- // Uhrzeit
- { NULL, ALVLT_String, { NULL, 0l, 0l }, ALVAH_HCenter, ALVAV_VCenter,
- ALVLT_Time, ALVAH_Right, ALVAV_VCenter,
- offsetof(struct FSDirEntry, fse_Date),
- 0, ALV_STDFLAGS,
- NULL },
- };
-
-
- BOOL getargs(struct BackupOptions *Opts)
- {
- int erg = 0;
-
- ASSERT_VALID(Opts);
-
- GlobalFSStartCode = 0;
-
- if (!BeginFileSelect(Opts, &erg))
- return 0;
-
- EnableTapeMenu(Disks[Opts->bo_FirstUnit].TapeReq != NULL);
-
- while (FSwin && GlobalFSStartCode != FS_START && GlobalFSStartCode != FS_ABORT)
- {
- eingabe(0l);
- }
-
- CloseXGO(GlobalFSStartCode);
- EndFileSelect();
-
- return (BOOL) (FS_START == GlobalFSStartCode);
- }
-
-
- static UWORD ComputeX( UWORD value )
- {
- return ((UWORD) ((value * FontX) / 65535));
- }
-
-
- static UWORD ComputeY( UWORD value )
- {
- return ((UWORD) ((value * FontY) / 65535));
- }
-
-
- // Prüfung, ob <addr> im ROM liegt
- static short inROM(APTR addr)
- {
- return (short)(addr >= (APTR) 0xf80000 && addr <= (APTR) 0xffffff);
- }
-
- void InitFileSelect(struct BackupOptions *Opts)
- {
- ASSERT_VALID(Opts);
- BackupOpt = Opts;
-
- if (BackupOpt->bo_FSDirList == NULL)
- BackupOpt->bo_FSDirCount = 0;
- }
-
-
- static void FSRender( void )
- {
- DrawBevelBox( FSwin->RPort, OffX + ComputeX(3), OffY + ComputeY(2),
- ComputeX( 372 ),
- ComputeY( 62 ),
- GT_VisualInfo, vi,
- GTBB_Recessed, TRUE,
- TAG_DONE );
- }
-
-
- static void InitFS(void)
- {
- static BOOL First = TRUE;
- UWORD lc, tc;
- struct Gadget *g;
-
- CreateGadgetShort(&FSGadgetShort);
-
- if (FSGList)
- {
- if (FSwin)
- RemoveGList(FSwin, FSGList, -1);
-
- FreeGadgets(FSGList);
- FSGList = NULL;
-
- FreeBResources(&FSResourceList);
- }
-
- if (First)
- {
- FSWindowLimits.Left = ComputeX(DFLT_WIDTH) + OffX + WBScreen->BarHeight;
- FSWindowLimits.Top = ComputeY(MIN_FSHEIGHT);
- FSWindowLimits.Width = max(MAX_FSWIDTH, (( FileDisplayScr.sFont->tf_XSize * MAX_FSWIDTH) + 4 ) / 8);
-
- // Window-Größe begrenzen
- // ACHTUNG: FSWindowPos ist InnerHeight und InnerWidth !
- FSWindowPos.Width = min(FSWindowLimits.Width - OffX - WBScreen->BarHeight,
- max(FSWindowLimits.Left - OffX - WBScreen->BarHeight, FSWindowPos.Width));
- FSWindowPos.Height = max(FSWindowLimits.Top - OffY - WBScreen->WBorBottom, FSWindowPos.Height);
-
- FSGadgetOff[GDX_FSHelpGadget].Left = DFLT_WIDTH - FSNGad[GDX_FSHelpGadget].ng_LeftEdge;
- FSGadgetOff[GDX_FSGlobOptGadget].Left = DFLT_WIDTH - FSNGad[GDX_FSGlobOptGadget].ng_LeftEdge;
- FSGadgetOff[GDX_FSALVGadget].Width = DFLT_WIDTH - FSNGad[GDX_FSALVGadget].ng_Width;
- FSGadgetOff[GDX_FSALVGadget].Height = DFLT_HEIGHT - FSNGad[GDX_FSALVGadget].ng_Height;
- FSGadgetOff[GDX_FSDrawerGadget].Width = DFLT_WIDTH - FSNGad[GDX_FSDrawerGadget].ng_Width;
- FSGadgetOff[GDX_FSStartGadget].Top = DFLT_HEIGHT - FSNGad[GDX_FSStartGadget].ng_TopEdge;
- FSGadgetOff[GDX_FSParentGadget].Top = DFLT_HEIGHT - FSNGad[GDX_FSParentGadget].ng_TopEdge;
- FSGadgetOff[GDX_FSVolumesGadget].Top = DFLT_HEIGHT - FSNGad[GDX_FSVolumesGadget].ng_TopEdge;
- FSGadgetOff[GDX_FSRereadGadget].Top = DFLT_HEIGHT - FSNGad[GDX_FSRereadGadget].ng_TopEdge;
- FSGadgetOff[GDX_FSCancelGadget].Top = DFLT_HEIGHT - FSNGad[GDX_FSCancelGadget].ng_TopEdge;
- }
-
- // Texte für Cycle-Gadgets vorbereiten
- FSArcSetGadget0Labels[0] = (STRPTR) GetString(MSG_ARCSET_IGNORE_GAD);
- FSArcSetGadget0Labels[1] = (STRPTR) GetString(MSG_ARCSET_RESET_GAD);
- FSArcSetGadget0Labels[2] = (STRPTR) GetString(MSG_ARCSET_SET_GAD);
-
- MoreALVTags[0].ti_Data = (ULONG) myLocale;
-
- if ( ! ( g = CreateContext( &FSGList )))
- {
- alarm(GetString(MSG_CREATECONTEXT_FAIL), __FUNC__);
- myabort(20);
- }
-
- for( lc = 0, tc = 0; lc < FS_CNT; lc++ )
- {
- struct NewGadget ng;
-
- ng = FSNGad[lc];
-
- // Korrekturen für andere Window-Größen (nicht default)
- if (FSGadgetOff[lc].Left)
- ng.ng_LeftEdge = OffX + FSWindowPos.Width - ComputeX(FSGadgetOff[lc].Left);
- else
- ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
-
- if (FSGadgetOff[lc].Top)
- ng.ng_TopEdge = OffY + FSWindowPos.Height - ComputeY(FSGadgetOff[lc].Top);
- else
- ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
-
- if (GENERIC_KIND != FSGTypes[lc])
- {
- // Gadgets GENERIC_KIND werden nicht skaliert!
- if (FSGadgetOff[lc].Width)
- ng.ng_Width = FSWindowPos.Width - ComputeX(FSGadgetOff[lc].Width);
- else
- ng.ng_Width = ComputeX( ng.ng_Width );
-
- if (FSGadgetOff[lc].Height)
- ng.ng_Height = FSWindowPos.Height - ComputeY(FSGadgetOff[lc].Height);
- else
- ng.ng_Height = ComputeY( ng.ng_Height);
- }
-
- // bei GENRIC_KIND und IMAGEBUTTON_KIND Gadgets hat ng_GadgetText eine besondere Bedeutung!
- if (GENERIC_KIND != FSGTypes[lc] && IMAGEBUTTON_KIND != FSGTypes[lc])
- {
- if (ng.ng_GadgetText)
- ng.ng_GadgetText = (STRPTR) GetString((long) ng.ng_GadgetText);
- }
-
- ng.ng_VisualInfo = vi;
-
- if (NULL == ng.ng_TextAttr)
- ng.ng_TextAttr = WBScreen->Font;
-
- switch (FSGTypes[lc])
- {
- case GENERIC_KIND:
- {
- struct GenericGadgetImages *gImg = (struct GenericGadgetImages *) ng.ng_GadgetText;
-
- ng.ng_GadgetText = NULL;
- if (gImg)
- {
- // Breite + Höhe des Gadgets von den Images übernehmen
- ng.ng_Width = gImg->gi_Render->Width;
- ng.ng_Height = gImg->gi_Render->Height;
- }
- FSGadgets[lc] = g = CreateGadgetA((ULONG)FSGTypes[ lc ], g,
- &ng, (struct TagItem *) &FSGTags[ tc ]);
- if (g)
- {
- g->GadgetType |= GTYP_BOOLGADGET;
- g->Flags |= GFLG_GADGHIMAGE | GFLG_GADGIMAGE;
- g->Activation = GACT_RELVERIFY;
- g->GadgetRender = gImg->gi_Render;
- g->SelectRender = gImg->gi_Selected;
- }
-
- if (ng.ng_GadgetText)
- EnterGadgetShort(&ng, FSGTypes[lc], &FSGTags[ tc ], g, FSGadgetShort);
- }
- break;
-
- case ALVGAD_KIND:
- FSGadgets[lc] = g =
- CreateALVGad(&ng,
- GA_Previous, g,
- TAG_MORE, &FSGTags[tc],
- TAG_END);
- if (g)
- RememberBResource(BRES_ALVGADGET, g, &FSResourceList);
- break;
-
- case IMAGEBUTTON_KIND:
- {
- struct GenericGadgetImages *gImg = (struct GenericGadgetImages *) ng.ng_GadgetText;
- struct Image *RenderImage, *SelectedImage;
-
- ng.ng_GadgetText = NULL;
-
- // Skalierte Images erzeugen
- RenderImage = ScaleImage(gImg->gi_Render, ng.ng_Width, ng.ng_Height);
- if (RenderImage)
- RememberBResource(BRES_SCALEDIMAGE, RenderImage, &FSResourceList);
-
- SelectedImage = ScaleImage(gImg->gi_Selected, ng.ng_Width, ng.ng_Height);
- if (SelectedImage)
- RememberBResource(BRES_SCALEDIMAGE, SelectedImage, &FSResourceList);
-
- if (RenderImage && SelectedImage)
- {
- FSGadgets[lc] = g = CreateGadgetA(GENERIC_KIND, g, &ng, (struct TagItem *) &FSGTags[tc]);
- if (g)
- {
- g->GadgetType |= GTYP_BOOLGADGET;
- g->Activation = GACT_RELVERIFY;
- if (gImg)
- {
- g->Flags |= GFLG_GADGHIMAGE | GFLG_GADGIMAGE;
- g->GadgetRender = RenderImage;
- g->SelectRender = SelectedImage;
- }
- }
- }
- }
- break;
- default:
- FSGadgets[lc] = g = CreateGadgetA((ULONG)FSGTypes[ lc ], g,
- &ng, (struct TagItem *)&FSGTags[tc] );
-
- if (ng.ng_GadgetText)
- EnterGadgetShort(&ng, FSGTypes[lc], &FSGTags[ tc ], g, FSGadgetShort);
- break;
- }
-
- while( FSGTags[ tc ] ) tc += 2;
- tc++;
-
- if (NULL == g)
- {
- alarm(GetString(MSG_CREATEGAD_FAILED), __FUNC__);
- myabort(20);
- }
- }
-
- if (FSwin)
- {
- // erzeugte Gadgets einhängen wenn FSwin offen!
- RefreshWindowFrame(FSwin);
- AddGList(FSwin, FSGList, ~0, ~0, NULL);
- RefreshGList(FSGList, FSwin, NULL, ~0);
- GT_RefreshWindow(FSwin, NULL);
- }
-
- // kein Online Help ohne AmigaGuide!
- GT_SetGadgetAttrs(FSGadgets[GDX_FSHelpGadget], FSwin, NULL,
- GA_Disabled, NULL == AmigaGuideBase,
- TAG_END);
-
- GT_SetGadgetAttrs(FSGadgets[GDX_FSPatternGadget], FSwin, NULL,
- GTST_String, SelectPattern.RawName,
- TAG_END);
-
- if (aktFSDir)
- {
- GT_SetGadgetAttrs(FSGadgets[GDX_FSDrawerGadget], FSwin, NULL,
- GTST_String, aktFSDir->fsd_Name,
- TAG_END);
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_Records, (aktFSDir && aktFSDir->fsd_DirCount) ? aktFSDir->fsd_EntryList[0] : NULL,
- TAG_END);
- }
-
- if (First && !SetupFSMenu())
- return;
-
- SetupBackupOpts(BackupOpt, "");
-
- First = FALSE;
- }
-
-
- static BOOL BeginFileSelect(struct BackupOptions *Opts, int *FSResult)
- {
- ASSERT_VALID(Opts);
-
- if (FSwin)
- return FALSE;
-
- *FSResult = 0;
- globalFSResult = FSResult;
-
- CalcGadgetScale(WBScreen, ScreenFont, &FontX, &FontY, &OffX, &OffY, 8, 11);
-
- InitFileSelect(Opts);
-
- GadgetHelp = IntuitionBase->LibNode.lib_Version >= 39;
- if (GadgetHelp)
- BackupHelpGroup = GetUniqueID(); // V39!
-
- SetFSListFont(Opts);
- InitFS();
-
- FSwin = OpenWindowTags(NULL,
- WA_Left, FSWindowPos.Left,
- WA_Top, FSWindowPos.Top,
- WA_InnerWidth, FSWindowPos.Width,
- WA_InnerHeight, FSWindowPos.Height,
- WA_IDCMP, STRINGIDCMP | BUTTONIDCMP | CYCLEIDCMP
- | CHECKBOXIDCMP | SCROLLERIDCMP | ARROWIDCMP
- | IDCMP_NEWSIZE | IDCMP_MENUPICK
- | IDCMP_RAWKEY | IDCMP_ACTIVEWINDOW | IDCMP_VANILLAKEY
- | IDCMP_MENUHELP | IDCMP_REFRESHWINDOW
- | IDCMP_GADGETHELP | IDCMP_IDCMPUPDATE,
- WA_Flags, WFLG_SIZEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET
- |WFLG_SMART_REFRESH|WFLG_ACTIVATE,
- WA_Gadgets, FSGList,
- WA_NewLookMenus, TRUE,
- WA_MenuHelp, TRUE,
- WA_AutoAdjust, TRUE,
- WA_HelpGroup, BackupHelpGroup,
- WA_ScreenTitle, BackupScreenTitle,
- WA_PubScreen, WBScreen,
- TAG_END);
-
- if (NULL == FSwin)
- {
- alarm(GetString(MSG_CANNOT_OPEN_WINDOW), __FUNC__, "FSWin");
- return FALSE;
- }
-
- GT_RefreshWindow(FSwin, NULL);
-
- WindowLimits(FSwin, FSWindowLimits.Left,
- FSWindowLimits.Top, FSWindowLimits.Width,
- MAX_FSHEIGHT);
-
- FSRender();
-
- if (AppPort)
- {
- myAppWindow = AddAppWindowA(AMID_FILESELECT, (ULONG) FSwin,
- FSwin, AppPort, NULL);
- }
-
- // myFont einstellen
- if (myFont)
- SetFont(FSwin->RPort, myFont);
-
- FSInput = AddBInputHandler(1L << FSwin->UserPort->mp_SigBit, HandleFSMsg);
-
- MenuWin = FSwin;
- SetMenuStrip(FSwin, FSMenuList);
-
- if (FSwin->Width - FSwin->BorderLeft - FSwin->BorderRight != FSWindowPos.Width
- || FSwin->Height - FSwin->BorderTop - FSwin->BorderBottom != FSWindowPos.Height)
- {
- // Window paßte nicht auf den Schirm und wurde vom System verkleinert!
- SizeFSWindow(WSC_SizeAdjusted);
- }
- else
- SizeFSWindow(WSC_SameSize);
-
- SetMenus(BackupOpt);
-
- DisplaySelectCount();
-
- if (NULL == aktFSDir)
- GetFSDir(Opts->bo_CurrentDir, NULL);
-
- ((struct Process*) FindTask(NULL))->pr_WindowPtr = FSwin;
-
- return TRUE;
- }
-
-
- static void EndFileSelect(void)
- {
- EndByteCount();
-
- RemBInputHandler(&FSInput);
-
- if (myAppWindow)
- {
- struct AppMessage *AppMsg;
-
- // Message Port leeren !
- while (AppMsg = (struct AppMessage *) GetMsg(AppPort) )
- ReplyMsg((struct Message *) AppMsg);
-
- RemoveAppWindow(myAppWindow);
- myAppWindow = NULL;
- }
-
- if (FSwin)
- {
- ((struct Process*) FindTask(NULL))->pr_WindowPtr = NULL;
-
- if (MenuWin == FSwin)
- {
- ClearMenuStrip(MenuWin);
- MenuWin = NULL;
- }
-
- SafeCloseWindow(&FSwin);
- }
-
- if (FSMenuList)
- {
- FreeMenus(FSMenuList);
- FSMenuList = NULL;
- }
- if (FSGList)
- {
- FreeGadgets(FSGList);
- FSGList = NULL;
- }
-
- FreeBResources(&FSResourceList);
-
- if (FileDisplayScr.sFont)
- {
- CloseFont(FileDisplayScr.sFont);
- FileDisplayScr.sFont = NULL;
- }
-
- DestroyGadgetShort(&FSGadgetShort);
- }
-
-
- void CleanUpFS(void)
- {
- struct FSDir *dir;
- unsigned long n;
-
- EndFileSelect();
-
- if (BackupOpt && BackupOpt->bo_FSDirList)
- {
- for (n=0; n<BackupOpt->bo_FSDirCount; n++)
- {
- dir = BackupOpt->bo_FSDirList[n];
- if (dir)
- {
- EmptyFSDir(dir);
- if (dir->fsd_ListSize)
- {
- free(dir->fsd_EntryList);
- }
- dir->fsd_ListSize = 0;
- if (dir->fsd_Name)
- free(dir->fsd_Name);
- free(dir);
- BackupOpt->bo_FSDirList[n] = NULL;
- }
- }
- free(BackupOpt->bo_FSDirList);
- BackupOpt->bo_FSDirList = NULL;
- MainFSDirLength = 0L;
- BackupOpt->bo_FSDirCount = 0L;
- }
- }
-
-
- // AppMessage behandeln, in am_UserData ist das jeweilige Window eingetragen
- int HandleAppMsg(void)
- {
- struct AppMessage *AppMsg;
- struct Window *AppMsgWindow;
-
- while ((AppMsg = (struct AppMessage *) GetMsg(AppPort)) != NULL)
- {
- AppMsgWindow = NULL;
-
- if (AppMsg->am_Version == AM_VERSION)
- {
- switch (AppMsg->am_Type)
- {
- case AMTYPE_APPWINDOW:
- AppMsgWindow = (struct Window *) AppMsg->am_UserData;
- UseDiskObject(AppMsg);
- break;
-
- case AMTYPE_APPICON:
- if (0 == AppMsg->am_NumArgs)
- {
- // Doppelklick auf AppIcon
- SignalUnIconifyMainWindow();
- }
- break;
- }
- }
-
- ReplyMsg((struct Message *) AppMsg);
-
- if (AppMsgWindow)
- ActivateWindow(AppMsgWindow);
- }
-
- return FALSE;
- }
-
-
- static int HandleFSMsg(void)
- {
- struct IntuiMessage *msg;
- int result;
- short *abortFSRead;
-
- abortFSRead = FSGadgetShortHook.h_Data;
-
- while (FSwin && (msg = GT_GetIMsg(FSwin->UserPort)) )
- result = FS_IDCMPHandler(msg, abortFSRead);
-
- if (FSwin)
- DisplaySelectCount();
-
- return result;
- }
-
-
- static int FS_IDCMPHandler(struct IntuiMessage *msg, short *abortFSRead)
- {
- ULONG class;
- USHORT code, qualifier;
- int result = FS_NOTHING;
- struct Gadget *curgadget;
-
- ASSERT_VALID(msg);
- class = msg->Class;
- code = msg->Code;
- qualifier = msg->Qualifier;
- curgadget = (struct Gadget *)msg->IAddress;
-
- GT_ReplyIMsg(msg);
-
- if (FSwin->ReqCount)
- return result;
-
- switch (class)
- {
- case IDCMP_ACTIVEWINDOW:
- d(printf("IDCMP_ACTIVEWINDOW\n"));
- if (MenuWin)
- ClearMenuStrip(MenuWin);
- activeWindow = MenuWin = FSwin;
- ResetMenuStrip(FSwin, FSMenuList);
-
- SetHelpPointer(activeWindow, HelpActive);
- break;
-
- case IDCMP_NEWSIZE:
- d(printf("IDCMP_NEWSIZE\n"));
- SizeFSWindow(WSC_SizeChanged);
- break;
-
- case IDCMP_VANILLAKEY:
- d(printf("IDCMP_VANILLAKEY\n"));
-
- result = HandleGadgetShort(FSGadgetShort, FSwin, code, &FSGadgetShortHook);
- break;
-
- case IDCMP_GADGETHELP:
- d(printf("IDCMP_GADGETHELP\n"));
- if (curgadget == NULL)
- {
- // Nicht über unserem Window
- }
- else if ((APTR) curgadget == (APTR) FSwin)
- {
- // über unserem Window
- CallHelp(HELPID_FSWINDOW_OUTSIDE, TRUE); // im FSWindow
- }
- else
- HandleFSGadgetHelp(curgadget, code);
- break;
-
- case IDCMP_MENUHELP:
- d(printf("IDCMP_MENUHELP\n"));
- result = ProcessFSMenuHelp(code);
- break;
-
- case IDCMP_GADGETUP:
- d(printf("IDCMP_GADGETUP\n"));
- if (HelpActive && !GadgetHelp)
- HandleFSGadgetHelp(curgadget, code);
- else
- {
- result = HandleFSGadget(curgadget, code, abortFSRead);
- }
- break;
-
- case IDCMP_IDCMPUPDATE:
- switch (code)
- {
- case IDCMPCODE_SELECTRECORD:
- {
- struct FSSelectedRecord *FSS;
-
- FSS = (struct FSSelectedRecord *) RemHead((struct List *) &SelectRecordsList);
- if (FSS)
- {
- if (FSS->fsr_Record->fse_fsRecord.alr_Flags & ALRF_SELECTED)
- InternalSelectEntry(aktFSDir, FSS->fsr_Record, TRUE, TRUE, 0, TRUE);
- else
- InternalSelectEntry(aktFSDir, FSS->fsr_Record, FALSE, TRUE, 0, TRUE);
-
- free(FSS);
- }
- }
- break;
- }
- break;
-
- case IDCMP_INTUITICKS:
- {
- // bei einem Mausklick auf ein Drawer-Icon wird an die <SubDirRecordsList> ein Eintrag angehängt
- // leider wird dabei keine direkte Benachrichtigung geschickt.
- // Deshalb wird die <SubDirRecordsList> bei jeden INTUITICK gepollt - Nicht schön, aber funktional!
- struct FSSelectedRecord *FSS;
-
- do {
- FSS = (struct FSSelectedRecord *) RemHead((struct List *) &SubDirRecordsList);
- d(kprintf(__FUNC__ "/%ld: FSS=%08lx\n", __LINE__, FSS));
-
- if (FSS)
- {
- // Dir. wechseln
- if (abortFSRead)
- *abortFSRead = TRUE;
- FSSubDir(FSS->fsr_Record);
- free(FSS);
- }
- } while (FSS);
- }
- break;
-
- case IDCMP_MENUPICK:
- d(printf("IDCMP_MENUPICK\n"));
- result = ProcessFSMenu(code, BackupOpt);
- break;
-
- case IDCMP_RAWKEY:
- d(printf("IDCMP_RAWKEY\n"));
- if (GADCODE_HELP == code)
- ToggleHelp();
- else
- ScrollFSWindow(code, qualifier);
- break;
-
- case IDCMP_REFRESHWINDOW:
- d(printf("IDCMP_REFRESHWINDOW\n"));
- // This handling is REQUIRED with GadTools.
- GT_BeginRefresh(FSwin);
- GT_EndRefresh(FSwin, TRUE);
- break;
-
- default:
- d(printf("IDCMP=%08lx\n", class));
- break;
- }
-
- if ((GlobalFSStartCode == FS_ABORT) || (GlobalFSStartCode == FS_START))
- EndFileSelect();
-
- return result;
- }
-
-
- static void __interrupt HandleFSGadgetCallback(struct Hook *hook, struct Gadget *Gad, ULONG *Code)
- {
- short *abortFSRead = (short *) hook->h_Data;
-
- HandleFSGadget(Gad, (USHORT) *Code, abortFSRead);
- }
-
-
- static void HandleFSGadgetHelp(const struct Gadget *gad, USHORT code)
- {
- ASSERT_VALID(gad);
- if ((!GadgetHelp && gad->GadgetID == GD_FSHelpGadget) ||
- ((gad->GadgetType & GTYP_GTYPEMASK) == GTYP_STRGADGET
- && code == GADCODE_HELP) )
- {
- StopHelp();
- }
- else if (!(gad->GadgetType & GTYP_SYSGADGET))
- CallHelp(gad->GadgetID, TRUE);
- }
-
-
- static short HandleFSGadget(struct Gadget *gad, USHORT code, short *abortFSRead)
- {
- struct NamePattern Pat;
- short result = FS_NOTHING;
-
- ASSERT_VALID(gad);
- Pat.isParsed = FALSE;
-
- switch (gad->GadgetID)
- {
- case GD_FSALVGadget:
- break;
-
- case GD_FSPatternGadget:
- if (HandleStrGadCode(code))
- GetPatternGadgetString();
- break;
-
- case GD_FSSelectAttrGadget:
- SelectFSAttr(TRUE);
- break;
-
- case GD_FSDeselectAttrGadget:
- SelectFSAttr(FALSE);
- break;
-
- case GD_FSArcSetGadget:
- FSArchiveSelect = code;
- break;
-
- case GD_FSDrawerGadget:
- if (HandleStrGadCode(code))
- {
- if (abortFSRead)
- *abortFSRead = TRUE;
- GT_SetGadgetAttrs(FSGadgets[GDX_FSParentGadget], FSwin, NULL,
- GA_Disabled, FALSE,
- TAG_END);
- GetFSDir(GADSTRING(gad), NULL);
- }
- break;
-
- case GD_FSSwapDateGadget:
- SwapFromToDate(FSwin, FSGadgets[GDX_FSFromDateGadget],
- FSGadgets[GDX_FSToDateGadget]);
- break;
-
- case GD_FSStartGadget:
- if (FSFileSelectCount || FSDirSelectCount || aktCmdFile)
- {
- if (abortFSRead)
- *abortFSRead = TRUE;
- GlobalFSStartCode = FS_START;
- }
- else
- alarm(GetString(MSG_NOTHING_SELECTED));
- break;
-
- case GD_FSVolumesGadget:
- if (abortFSRead)
- *abortFSRead = TRUE;
- aktFSDir = GetVolumes();
- GT_SetGadgetAttrs(FSGadgets[GDX_FSParentGadget], FSwin, NULL,
- GA_Disabled, TRUE,
- TAG_END);
- GT_SetGadgetAttrs(FSGadgets[GDX_FSDrawerGadget], FSwin, NULL,
- GTST_String, aktFSDir->fsd_Name,
- TAG_END);
- DisplayFSList(aktFSDir);
- break;
-
- case GD_FSFromDateGadget:
- case GD_FSToDateGadget:
- HandleStrGadCode(code);
- break;
-
- case GD_FSFromOnGadget:
- GT_SetGadgetAttrs(FSGadgets[GDX_FSFromDateGadget], FSwin, NULL,
- GA_Disabled, !code,
- TAG_END);
- break;
-
- case GD_FSToOnGadget:
- GT_SetGadgetAttrs(FSGadgets[GDX_FSToDateGadget], FSwin, NULL,
- GA_Disabled, !code,
- TAG_END);
- break;
-
- case GD_FSParentGadget:
- if (abortFSRead)
- *abortFSRead = TRUE;
- FSParentDir();
- break;
-
- case GD_FSCancelGadget:
- if (abortFSRead)
- *abortFSRead = TRUE;
- GlobalFSStartCode = FS_ABORT;
- break;
-
- case GD_FSRereadGadget:
- if (aktFSDir)
- {
- if (aktFSDir->fsd_isVolList)
- {
- aktFSDir = GetVolumes();
- DisplayFSList(aktFSDir);
- }
- else
- aktFSDir = ReadFSDir(aktFSDir->fsd_Name, aktFSDir, NULL);
- }
- break;
-
- case GD_FSGlobOptGadget:
- //??? SelectGadget(&FSWinGOGadget, FSwin, NULL, TRUE);
- GT_SetGadgetAttrs(FSGadgets[GDX_FSGlobOptGadget], FSwin, NULL,
- GA_Disabled, TRUE,
- TAG_END);
- BeginXGO(FSwin, BackupOpt);
- break;
-
- case GD_FSHelpGadget:
- ToggleHelp();
- break;
-
- default:
- if (isascii(gad->GadgetID))
- result = gad->GadgetID;
- break;
- }
-
- return result;
- }
-
-
- static void ScrollFSWindow(USHORT Code, USHORT Qualifier)
- {
- if (Code == GADCODE_UP)
- {
- if (Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_ScrollUp, ALV_PAGE_SCROLL,
- TAG_END);
- }
- else if (Qualifier & IEQUALIFIER_CONTROL)
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_TopLine, 0,
- TAG_END);
- }
- else
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_ScrollUp, 1,
- TAG_END);
- }
- }
- else if (Code == GADCODE_DOWN)
- {
- if (Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_ScrollDown, ALV_PAGE_SCROLL,
- TAG_END);
- }
- else if (Qualifier & IEQUALIFIER_CONTROL)
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_TopLine, ULONG_MAX,
- TAG_END);
- }
- else
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_ScrollDown, 1,
- TAG_END);
- }
- }
- else if (Code == GADCODE_LEFT)
- {
- if (Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_ScrollLeft, ALV_PAGE_SCROLL,
- TAG_END);
- }
- else if (Qualifier & IEQUALIFIER_CONTROL)
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_LeftPixelOffset, 0,
- TAG_END);
- }
- else
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_ScrollLeft, 1,
- TAG_END);
- }
- }
- else if (Code == GADCODE_RIGHT)
- {
- if (Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_ScrollRight, ALV_PAGE_SCROLL,
- TAG_END);
- }
- else if (Qualifier & IEQUALIFIER_CONTROL)
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_LeftPixelOffset, ULONG_MAX,
- TAG_END);
- }
- else
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_ScrollRight, 1,
- TAG_END);
- }
- }
- }
-
-
- static BOOL HandleStrGadCode(USHORT code)
- {
- BOOL Result = FALSE;
-
- switch (code)
- {
- case GADCODE_HELP:
- ToggleHelp();
- break;
- case GADCODE_UP:
- ScrollFSWindow(GADCODE_UP, 0);
- break;
- case GADCODE_PAGEUP:
- ScrollFSWindow(GADCODE_UP, IEQUALIFIER_LSHIFT);
- break;
- case GADCODE_TOP:
- ScrollFSWindow(GADCODE_UP, IEQUALIFIER_CONTROL);
- break;
- case GADCODE_DOWN:
- ScrollFSWindow(GADCODE_DOWN, 0);
- break;
- case GADCODE_PAGEDOWN:
- ScrollFSWindow(GADCODE_DOWN, IEQUALIFIER_LSHIFT);
- break;
- case GADCODE_BOTTOM:
- ScrollFSWindow(GADCODE_DOWN, IEQUALIFIER_CONTROL);
- break;
- case 0:
- Result = TRUE;
- break;
- }
-
- return Result;
- }
-
-
- void SizeFSWindow(enum WindowSizeChg NewSize)
- {
- static short LastWidth = 0;
- static short LastHeight = 0;
-
- ASSERT_VALID(FSwin);
-
- FSWindowPos.Left = FSwin->LeftEdge;
- FSWindowPos.Top = FSwin->TopEdge;
- FSWindowPos.Width = FSwin->Width - FSwin->BorderLeft - FSwin->BorderRight;
- FSWindowPos.Height = FSwin->Height - FSwin->BorderTop - FSwin->BorderBottom;
-
- InnerHeight = FSwin->Height - FSwin->BorderTop - FSwin->BorderBottom;
- InnerWidth = FSwin->Width - FSwin->BorderLeft - FSwin->BorderRight;
-
- switch (NewSize)
- {
- case WSC_SizeAdjusted:
- EraseRect(FSwin->RPort, FSwin->BorderLeft, FSwin->BorderTop,
- FSwin->Width - FSwin->BorderRight - 1,
- FSwin->Height - FSwin->BorderBottom - 1);
-
- InitFS(); // Gadgets neu erzeugen
-
- FSRender();
- break;
-
- case WSC_SizeChanged:
- if (FSwin->Height != LastHeight || FSwin->Width != LastWidth)
- {
- if (LastWidth > FSwin->BorderLeft && LastHeight > FSwin->BorderTop)
- {
- EraseRect(FSwin->RPort, FSwin->BorderLeft, FSwin->BorderTop,
- min(FSwin->Width, LastWidth) - FSwin->BorderRight - 1,
- min(FSwin->Height, LastHeight) - FSwin->BorderBottom - 1);
- }
-
- InitFS(); // Gadgets neu erzeugen
-
- FSRender();
- }
- break;
- }
-
- LastHeight = FSwin->Height;
- LastWidth = FSwin->Width;
- }
-
-
- static char *NormalizeName(const char *Name)
- {
- BPTR __aligned DirLock;
- char *NormalizedName;
-
- ASSERT_VALID(Name);
-
- if (*Name == '\0') // "" -> "", nichts normalisieren
- return strdup(Name);
-
- DirLock = Lock((STRPTR) Name, ACCESS_READ);
- if (DirLock == NULL)
- {
- alarm(GetString(MSG_FS_CANNOTLOCK), (STRPTR) Name, GetIoErrText());
- return NULL;
- }
-
- NormalizedName = GetFullPathName(DirLock);
- UnLock(DirLock);
-
- return NormalizedName;
- }
-
-
- static struct FSDir *GetFSDir(const char *DirName, struct FSDirEntry *Parent)
- {
- struct FSDir *dir;
- char *NormalizedName;
-
- ASSERT_VALID(DirName);
- ASSERT_VALID0(Parent);
-
- DirName = NormalizedName = NormalizeName(DirName);
- if (NULL == NormalizedName)
- return NULL;
-
- dir = SearchFSDir(DirName); // Directory bereits angelegt ?
- if (dir)
- {
- if (dir->fsd_isComplete)
- {
- aktFSDir = dir;
- GT_SetGadgetAttrs(FSGadgets[GDX_FSDrawerGadget], FSwin, NULL,
- GTST_String, aktFSDir->fsd_Name,
- TAG_END);
- DisplayFSList(dir);
- }
- else
- {
- dir = aktFSDir = ReadFSDir(DirName, dir, Parent);
- }
- }
- else
- {
- // Directory neu lesen
- dir = aktFSDir = ReadFSDir(DirName, NULL, Parent);
- }
-
- free(NormalizedName);
-
- return dir;
- }
-
-
- static struct FSDir *ReadFSDir(const char *DirName, struct FSDir *Dir, struct FSDirEntry *Parent)
- {
- char *NormalizedName;
- struct FSDir *LastDir;
- struct FSDirEntry *FSe, *FSold;
- short abortFSRead;
- unsigned long index, MinIndex, Step;
- struct FSDir *ParentDir;
- enum SelectType ParentSelected = ST_None;
- struct MinList NewEntryList;
- struct NextFileInfo nfInfo;
-
- ASSERT_VALID(DirName);
- ASSERT_VALID0(Dir);
- ASSERT_VALID0(Parent);
-
- if (!BeginDir(DirName, &nfInfo))
- {
- EndDir(&nfInfo);
- return NULL;
- }
-
- GT_SetGadgetAttrs(FSGadgets[GDX_FSRereadGadget], FSwin, NULL,
- GA_Disabled, TRUE,
- TAG_END);
-
- NewList((struct List *) &NewEntryList);
-
- DirName = NormalizedName = GetFullPathName(nfInfo.nfi_DirLock);
-
- if (Dir && ST_None != Dir->fsd_ParentSelected)
- ParentSelected = ST_Selected;
-
- // Suchen nach einem bereits ausgewählten Parent Directory
- index = 0l;
- do {
- ParentDir = LookUpParentDir(DirName, &index);
-
- if (ParentDir && ParentDir->fsd_ParentSelected == ST_Selected)
- ParentSelected = ST_Selected;
- } while (ParentDir && !ParentSelected);
-
- if (Parent && ST_Selected == Parent->fse_Selected)
- ParentSelected = ST_Selected;
-
- LastDir = Dir;
-
- // Dir immer NEU anlegen
- Dir = MakeFSDir(DirName, NULL);
-
- free(NormalizedName);
-
- GT_SetGadgetAttrs(FSGadgets[GDX_FSDrawerGadget], FSwin, NULL,
- GTST_String, Dir->fsd_Name,
- TAG_END);
-
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_Records, (Dir && Dir->fsd_DirCount) ? Dir->fsd_EntryList[0] : NULL,
- TAG_END);
-
- FSGadgetShortHook.h_Data = &abortFSRead;
- aktFSDir = Dir;
- abortFSRead = FALSE;
-
- Dir->fsd_isComplete = FALSE;
-
- MinIndex = LONG_MAX;
- Step = 0;
- do {
- size_t NewIndex;
-
- FSe = NextFSDirEntry(&nfInfo);
- if (FSe)
- {
- int FSResult;
- struct FSNewEntry *NewEntry;
- #if 0
- char *FileName;
-
- FileName = ConcatDirName(Dir->fsd_Name, FSe->fse_Name);
- if (FileName)
- {
- FSe->fse_Icon = GetDiskObjectNew(FileName);
- free(FileName);
- }
- #endif
- // Select von Parent übernehmen
- if ((ParentSelected != ST_None) && FSFileMatch(BackupOpt, FSe))
- {
- InternalSelectEntry(Dir, FSe,
- ParentSelected == ST_Selected, FALSE, 1, TRUE);
- }
-
- if (!isFile(FSe))
- FSe->fse_HasSelects = LookUpFSDir(Dir->fsd_Name, FSe->fse_Name);
-
- FSold = LastDir ? FindFSEntry(FSe->fse_Name, LastDir) : NULL;
-
- NewIndex = InsertFSe(Dir, FSe);
-
- if (FSold && (ST_Selected == FSold->fse_Selected))
- SelectDirEntry(Dir, NewIndex, FALSE);
-
- NewEntry = malloc(sizeof(struct FSNewEntry));
- if (NewEntry)
- {
- struct FSNewEntry *LastEntry;
-
- NewEntry->fsn_Insert.ari_InsertAfter = (NewIndex > 0) ?
- &Dir->fsd_EntryList[NewIndex - 1]->fse_fsRecord: NULL;
- NewEntry->fsn_Insert.ari_NewRecords = &FSe->fse_fsRecord;
- NewEntry->fsn_Insert.ari_MoreInsert = NULL;
-
- LastEntry = (struct FSNewEntry *) RemTail((struct List *) &NewEntryList);
- if (LastEntry)
- {
- LastEntry->fsn_Insert.ari_MoreInsert = &NewEntry->fsn_Insert;
- AddTail((struct List *) &NewEntryList, &LastEntry->fsn_Node);
- }
- AddTail((struct List *) &NewEntryList, &NewEntry->fsn_Node);
- }
-
- MinIndex = min(NewIndex, MinIndex);
-
- if (Step >= FSDIR_STEP)
- {
-
- Step = 0;
- MinIndex = LONG_MAX;
-
- InsertEntryList((struct List *) &NewEntryList, FALSE);
- }
-
- DuplicateOldEntry(Dir, LastDir, FSe);
-
- // Während des Lesens des Directories auf Eingaben reagieren...
- FSResult = chkinput();
- if (globalFSResult && FSResult)
- {
- *globalFSResult = FSResult;
- if (FS_ABORT == FSResult || FS_START == FSResult)
- GlobalFSStartCode = FSResult;
- }
-
- Step++;
- }
-
- // <ParentSelected> mitführen falls <Dir> zwischenzeitlich ausgewählt wurde
- if (ST_None != Dir->fsd_ParentSelected)
- ParentSelected = ST_Selected;
- } while (!abortFSRead && FSe && FSwin);
-
- InsertEntryList((struct List *) &NewEntryList, abortFSRead);
-
- if (!abortFSRead)
- {
- // Länge der Liste auf <DirCount+2> begrenzen, um keinen unnötigen Speicherplatz zu belegen
- SetFSDirListSize(Dir, Dir->fsd_DirCount + 2);
-
- Dir->fsd_isComplete = TRUE;
- }
-
- if (LastDir)
- {
- struct FSDirEntry **vList;
- unsigned short vCount;
-
- // Einträge in LastDir und Dir vertauschen. Die alten Einträge aus Dir
- // werden dann zusammen mit LastDir vernichtet.
-
- vCount = LastDir->fsd_DirCount;
- LastDir->fsd_DirCount = Dir->fsd_DirCount;
- Dir->fsd_DirCount = vCount;
-
- vList = LastDir->fsd_EntryList;
- LastDir->fsd_EntryList = Dir->fsd_EntryList;
- Dir->fsd_EntryList = vList;
-
- LastDir->fsd_isComplete = Dir->fsd_isComplete;
-
- RemoveFSDir(Dir);
- aktFSDir = LastDir;
- }
-
- FSGadgetShortHook.h_Data = NULL;
- EndDir(&nfInfo);
-
- GT_SetGadgetAttrs(FSGadgets[GDX_FSRereadGadget], FSwin, NULL,
- GA_Disabled, FALSE,
- TAG_END);
-
- return aktFSDir;
- }
-
-
- static void InsertEntryList(struct List *EntryList, BOOL ClearOnly)
- {
- struct FSNewEntry *OldEntry;
-
- OldEntry = (struct FSNewEntry *) RemHead(EntryList);
- if (OldEntry && !ClearOnly)
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_InsertRecords, &OldEntry->fsn_Insert,
- TAG_END);
- }
-
- // NewEntryList wieder leeren
- while (OldEntry)
- {
- free(OldEntry);
-
- OldEntry = (struct FSNewEntry *) RemHead(EntryList);
- }
- }
-
-
- static short BeginDir(const char *DirName, struct NextFileInfo *nfInfo)
- {
- ASSERT_VALID(DirName);
- ASSERT_VALID(nfInfo);
-
- nfInfo->nfi_eaControl = AllocDosObject(DOS_EXALLCONTROL, NULL);
- if (NULL == nfInfo->nfi_eaControl)
- return NULL;
-
- nfInfo->nfi_eaBuffer = malloc(EXALL_BUFFSIZE);
- if (NULL == nfInfo->nfi_eaBuffer)
- return NULL;
-
- nfInfo->nfi_DirLock = Lock((STRPTR) DirName, ACCESS_READ);
- if (nfInfo->nfi_DirLock == NULL)
- return FALSE;
-
- // !!!!! lebenswichtige Initialisierung für ExAll() !!!!!
- nfInfo->nfi_eaControl->eac_LastKey = 0;
-
- ExAllNFInfo(nfInfo, ED_DATE);
-
- return TRUE;
- }
-
-
- static void EndDir(struct NextFileInfo *nfInfo)
- {
- ASSERT_VALID(nfInfo);
-
- if (nfInfo->nfi_eaControl && nfInfo->nfi_eaBuffer && nfInfo->nfi_eaMore)
- {
- // ExAll() war noch nicht fertig
- ExAllEnd(nfInfo->nfi_DirLock, nfInfo->nfi_eaBuffer,
- EXALL_BUFFSIZE, ED_DATE, nfInfo->nfi_eaControl);
- }
- if (nfInfo->nfi_eaControl)
- {
- FreeDosObject(DOS_EXALLCONTROL, nfInfo->nfi_eaControl);
- nfInfo->nfi_eaControl = NULL;
- }
- if (nfInfo->nfi_eaBuffer)
- {
- free(nfInfo->nfi_eaBuffer);
- nfInfo->nfi_eaBuffer = NULL;
- }
- if (nfInfo->nfi_DirLock)
- {
- UnLock(nfInfo->nfi_DirLock);
- nfInfo->nfi_DirLock = NULL;
- }
- }
-
-
- static struct FSDirEntry *NextFSDirEntry(struct NextFileInfo *nfInfo)
- {
- struct FSDirEntry *result = NULL;
-
- ASSERT_VALID(nfInfo);
-
- while (NULL == nfInfo->nfi_eaData && nfInfo->nfi_eaMore)
- {
- ExAllNFInfo(nfInfo, ED_DATE);
- }
-
- if (nfInfo->nfi_eaData)
- {
- result = NewFSEntry(nfInfo->nfi_eaData->ed_Name,
- GetFibType(nfInfo->nfi_eaData->ed_Type, nfInfo->nfi_eaData->ed_Name, nfInfo->nfi_DirLock));
-
- if (result)
- {
- result->fse_Protection = nfInfo->nfi_eaData->ed_Prot;
- result->fse_Size = nfInfo->nfi_eaData->ed_Size;
-
- result->fse_Date.ds_Days = nfInfo->nfi_eaData->ed_Days;
- result->fse_Date.ds_Minute = nfInfo->nfi_eaData->ed_Mins;
- result->fse_Date.ds_Tick = nfInfo->nfi_eaData->ed_Ticks;
- }
-
- nfInfo->nfi_eaData = nfInfo->nfi_eaData->ed_Next;
- }
-
- return result;
- }
-
-
- static enum FType GetFibType(long EntryType, const STRPTR Name, BPTR DirLock)
- {
- enum FType result;
-
- ASSERT_VALID(Name);
- ASSERT_VALID(BADDR(DirLock));
-
- switch (EntryType)
- {
- case ST_SOFTLINK:
- result = SoftLinkType(Name, DirLock);
- break;
- case ST_LINKFILE:
- result = HardLinkFile;
- break;
- case ST_LINKDIR:
- result = HardLinkDir;
- break;
- default:
- result = (EntryType < 0) ? File : Directory;
- }
-
- return result;
- }
-
-
- struct FSDirEntry *AddFSEntry(struct FSDir *Dir, const char *Name, enum FType Typ)
- {
- struct FSDirEntry *FSe;
-
- ASSERT_VALID(Dir);
- ASSERT_VALID(Name);
-
- FSe = FindFSEntry(Name, Dir);
- if (!FSe)
- {
- FSe = NewFSEntry(Name, Typ);
-
- if (Dir->fsd_DirCount > 0)
- Dir->fsd_EntryList[Dir->fsd_DirCount - 1]->fse_fsRecord.alr_NextRecord = FSe;
- FSe->fse_fsRecord.alr_NextRecord = NULL;
-
- Dir->fsd_EntryList[Dir->fsd_DirCount] = FSe;
- Dir->fsd_DirCount++;
- }
-
- return FSe;
- }
-
-
- static struct FSDirEntry *NewFSEntry(const char *Name, enum FType Typ)
- {
- unsigned short l;
- char c;
- struct FSDirEntry *FSe;
-
- ASSERT_VALID(Name);
-
- l = strlen(Name);
- c = Name[l-1];
- if (':' != c && (Typ == Volume || Typ == Assign || Typ == Device))
- l++; // Platz lassen für ':'
-
- FSe = (struct FSDirEntry *) malloc(sizeof(struct FSDirEntry) + l);
- if (FSe == NULL)
- {
- alarm(GetString(MSG_OUTOFMEMORY), __FUNC__, "FSe", sizeof(struct FSDirEntry) + l);
- myabort(10);
- }
- FSe->fse_Contents = NULL;
- FSe->fse_HasSelects = FALSE;
- FSe->fse_Selected = ST_None;
- FSe->fse_ManualSelect = ST_None;
- FSe->fse_Typ = Typ;
- FSe->fse_NameLength = l;
- FSe->fse_Icon = NULL;
-
- FSe->fse_fsRecord.alr_RecordData = FSe;
- FSe->fse_fsRecord.alr_Flags = 0l;
- FSe->fse_fsRecord.alr_Font.afd_FontAttr = NULL;
- FSe->fse_fsRecord.alr_Font.afd_SoftStyleStyle = FS_NORMAL;
- FSe->fse_fsRecord.alr_Font.afd_SoftStyleEnable = FS_NORMAL;
- FSe->fse_fsRecord.alr_NextRecord = NULL;
- FSe->fse_fsRecord.alr_Private = NULL;
-
- strcpy(FSe->fse_Name, Name);
- if (':' != c && (Typ == Volume || Typ == Assign || Typ == Device))
- strcat(FSe->fse_Name, ":");
-
- // Hilite-Markierung für Directories setzen
- if (!isFile(FSe))
- FSe->fse_fsRecord.alr_Flags |= ALRF_HILITE;
-
- switch (Typ)
- {
- case SoftLinkDir:
- case Directory:
- case HardLinkDir:
- case EmptyDir:
- FSe->fse_Image = &DrawerImage;
- break;
- case Assign:
- FSe->fse_fsRecord.alr_Flags |= ALRF_HILITE; // Hilite-Markierung für Assigns setzen
- FSe->fse_Image = &AssignImage;
- break;
- case Volume:
- FSe->fse_Image = &VolumeImage;
- break;
- default:
- FSe->fse_Image = NULL;
- break;
- }
-
- return FSe;
- }
-
-
- static void DestroyFSEntry(struct FSDirEntry **FSe)
- {
- if ((*FSe)->fse_Icon)
- {
- FreeDiskObject((*FSe)->fse_Icon);
- (*FSe)->fse_Icon = NULL;
- }
- free(*FSe);
- *FSe = NULL;
- }
-
-
- struct FSDir *CreateFSDir(const char *DirName, struct BackupOptions *Options)
- {
- struct FSDir *Parent, *Dir;
- char *NormalizedName = NULL;
-
- ASSERT_VALID(DirName);
-
- if (*DirName)
- {
- // nicht bei Volume-Listen!
- DirName = NormalizedName = NormalizeName(DirName);
- if (DirName == NULL)
- return NULL;
- }
-
- Dir = SearchFSDir(DirName);
- if (!Dir)
- Dir = MakeFSDir(DirName, Options);
-
- if (Parent = SearchFSDir(FindParentName((STRPTR) DirName)))
- Dir->fsd_ParentEntry = FindFSEntry(NurName(DirName), Parent);
-
- if (NormalizedName)
- free(NormalizedName);
-
- return Dir;
- }
-
-
- static struct FSDir *MakeFSDir(const char *DirName, struct BackupOptions *Options)
- {
- struct FSDir *dir;
-
- ASSERT_VALID(DirName);
-
- dir = calloc(sizeof(struct FSDir), 1);
- if (dir == NULL)
- {
- alarm(GetString(MSG_OUTOFMEMORY), __FUNC__, "dir", sizeof(struct FSDir));
- myabort(10);
- }
-
- dir->fsd_Name = strdup(DirName);
- if (dir->fsd_Name == NULL)
- {
- alarm(GetString(MSG_OUTOFMEMORY), __FUNC__, "Name", strlen(DirName));
- myabort(10);
- }
-
- dir->fsd_ParentEntry = NULL;
- dir->fsd_DirCount = 0;
- dir->fsd_SelectCount = 0;
- dir->fsd_isComplete = FALSE;
- dir->fsd_ParentSelected = FALSE;
- dir->fsd_HasSelects = FALSE;
- dir->fsd_isVolList = FALSE;
- dir->fsd_ListSize = DEFAULTLISTSIZE;
- dir->fsd_DirOptions = Options;
- dir->fsd_TopLine = 0l;
-
- dir->fsd_EntryList = (struct FSDirEntry **) calloc(dir->fsd_ListSize, sizeof(struct FSDirEntry *));
- if (dir->fsd_EntryList == NULL)
- {
- alarm(GetString(MSG_OUTOFMEMORY), __FUNC__, "DirList[1]", dir->fsd_ListSize * sizeof(struct FSDirEntry *));
- myabort(10);
- }
-
- if (BackupOpt->bo_FSDirCount >= MainFSDirLength)
- {
- // BackupOpt->bo_FSDirList verlängern
- MainFSDirLength += DEFAULTLISTSIZE;
- if (BackupOpt->bo_FSDirList)
- {
- BackupOpt->bo_FSDirList = realloc(BackupOpt->bo_FSDirList,
- MainFSDirLength * sizeof(struct FSDir *));
- }
- else
- {
- BackupOpt->bo_FSDirList = calloc(MainFSDirLength,
- sizeof(struct FSDir *));
- }
-
- if (BackupOpt->bo_FSDirList == NULL)
- {
- alarm(GetString(MSG_OUTOFMEMORY), __FUNC__, "DirList[2]", MainFSDirLength * sizeof(struct FSDir *));
- myabort(10);
- }
- }
-
- // neues Directory eintragen
- BackupOpt->bo_FSDirList[BackupOpt->bo_FSDirCount++] = dir;
-
- return dir;
- }
-
-
- // Eintrag <Dir> aus BackupOpt->bo_FSDirList entfernen und auflösen
- static void RemoveFSDir(struct FSDir *Dir)
- {
- unsigned long n;
- short found;
- unsigned short m;
-
- ASSERT_VALID(Dir);
-
- for (found=0, n=0; !found && n<BackupOpt->bo_FSDirCount; n++)
- {
- found = BackupOpt->bo_FSDirList[n] == Dir;
- if (found)
- {
- // SelectCount für Dirs und Files korrigieren
- for (m=0; m<Dir->fsd_DirCount; m++)
- {
- if (ST_Selected == Dir->fsd_EntryList[m]->fse_Selected)
- {
- if (isFile(Dir->fsd_EntryList[m]))
- FSFileSelectCount--;
- else
- FSDirSelectCount--;
- }
- }
- // Dir aus der Liste streichen
- while (n < BackupOpt->bo_FSDirCount-1)
- {
- BackupOpt->bo_FSDirList[n] = BackupOpt->bo_FSDirList[n+1];
- n++;
- }
- }
- }
-
- EmptyFSDir(Dir);
- free(Dir);
-
- BackupOpt->bo_FSDirCount--;
- }
-
-
- // EntryList um DEFAULTLISTSIZE verlängern
- static void ExtendFSDir(struct FSDir *dir)
- {
- ASSERT_VALID(dir);
- SetFSDirListSize(dir, dir->fsd_ListSize + DEFAULTLISTSIZE);
- }
-
-
- // EntryList auf <NewSize> einstellen
- static void SetFSDirListSize(struct FSDir *dir, unsigned long NewSize)
- {
- ASSERT_VALID(dir);
- dir->fsd_ListSize = NewSize;
-
- dir->fsd_EntryList = realloc(dir->fsd_EntryList, NewSize * sizeof(struct FSDirEntry *));
- if (dir->fsd_EntryList == NULL)
- {
- alarm(GetString(MSG_OUTOFMEMORY), __FUNC__, "EntryList", NewSize * sizeof(struct FSDirEntry *));
- myabort(10);
- }
- }
-
-
- // <FSe> in <Dir> finden und Anzeige aktualisieren
- static void FindAndRedisplayDirEntry(struct FSDir *Dir, struct FSDirEntry *FSe,
- ULONG FirstColumn, ULONG LastColumn, enum RedisplayMode Changed)
- {
- ULONG RecNo;
-
- ASSERT_VALID(Dir);
- ASSERT_VALID(FSe);
-
- if (aktFSDir != Dir)
- return; // keine Anzeige wenn dies nicht das aktuelle Directory ist!
-
- // RecordNummer von <FSe> in <Dir> finden
- for (RecNo=0; RecNo<Dir->fsd_DirCount; RecNo++)
- {
- if (Dir->fsd_EntryList[RecNo] == FSe)
- {
- struct ALVRecordChange rChg;
-
- rChg.arc_FirstRecord = &FSe->fse_fsRecord;
- rChg.arc_RecordCount = 1;
- rChg.arc_FirstColumnNo = FirstColumn;
- rChg.arc_LastColumnNo = LastColumn;
- rChg.arc_ContentsChanged = RDM_ContentsChanged == Changed;
-
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_InvalidateRecords, &rChg,
- TAG_END);
-
- break;
- }
- }
-
- }
-
-
- static void DisplayFSList(struct FSDir *Dir)
- {
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_Records, (Dir && Dir->fsd_DirCount) ? Dir->fsd_EntryList[0] : NULL,
- TAG_END);
- }
-
-
- void SortAllFSDirs(void)
- {
- size_t n;
-
- for (n=0; n<BackupOpt->bo_FSDirCount; n++)
- {
- SortFSList(BackupOpt->bo_FSDirList[n]);
- }
- }
-
-
- static void SortFSList(struct FSDir *dir)
- {
- size_t n;
-
- ASSERT_VALID(dir);
-
- qsort((char *) dir->fsd_EntryList, dir->fsd_DirCount,
- sizeof(struct FSDirEntry *), BackupOpt->bo_FSCompare);
-
- // ALVRecords richtig verketten
- for (n=0; n<dir->fsd_DirCount; n++)
- {
- if (n < dir->fsd_DirCount - 1)
- dir->fsd_EntryList[n]->fse_fsRecord.alr_NextRecord = dir->fsd_EntryList[n + 1];
- else
- dir->fsd_EntryList[n]->fse_fsRecord.alr_NextRecord = NULL;
- }
-
- // frisch sortierte Liste anzeigen
- if (dir == aktFSDir)
- DisplayFSList(dir);
- }
-
-
- int FSCompareName(struct FSDirEntry **fs1, struct FSDirEntry **fs2)
- {
- ASSERT_VALID(*fs1);
- ASSERT_VALID(*fs2);
-
- if (DifferentType(*fs1, *fs2))
- {
- switch (BackupOpt->bo_WhereSortDirs)
- {
- case DirFirst:
- return (*fs2)->fse_Typ - (*fs1)->fse_Typ;
- break;
- case DirLast:
- return (*fs1)->fse_Typ - (*fs2)->fse_Typ;
- break;
- case DirBetween:
- break;
- }
- }
-
- return stricmp((*fs1)->fse_Name, (*fs2)->fse_Name);
- }
-
-
- // absteigend nach Datum & Uhrzeit sortieren
- int FSCompareDate(struct FSDirEntry **fs1, struct FSDirEntry **fs2)
- {
- ASSERT_VALID(*fs1);
- ASSERT_VALID(*fs2);
-
- if (DifferentType(*fs1, *fs2))
- {
- switch (BackupOpt->bo_WhereSortDirs)
- {
- case DirFirst:
- return (*fs2)->fse_Typ - (*fs1)->fse_Typ;
- break;
- case DirLast:
- return (*fs1)->fse_Typ - (*fs2)->fse_Typ;
- break;
- case DirBetween:
- break;
- }
- }
-
- if ((*fs1)->fse_Date.ds_Days != (*fs2)->fse_Date.ds_Days)
- return (*fs2)->fse_Date.ds_Days - (*fs1)->fse_Date.ds_Days;
-
- if ((*fs1)->fse_Date.ds_Minute != (*fs2)->fse_Date.ds_Minute)
- return (*fs2)->fse_Date.ds_Minute - (*fs1)->fse_Date.ds_Minute;
-
- return (*fs2)->fse_Date.ds_Tick - (*fs1)->fse_Date.ds_Tick;
- }
-
-
- // aufsteigend nach Größe sortieren
- int FSCompareSize(struct FSDirEntry **fs1, struct FSDirEntry **fs2)
- {
- ASSERT_VALID(*fs1);
- ASSERT_VALID(*fs2);
-
- if (DifferentType(*fs1, *fs2))
- {
- switch (BackupOpt->bo_WhereSortDirs)
- {
- case DirFirst:
- case DirBetween:
- return (*fs2)->fse_Typ - (*fs1)->fse_Typ;
- break;
- case DirLast:
- return (*fs1)->fse_Typ - (*fs2)->fse_Typ;
- break;
- }
- }
-
- return (int) ((*fs1)->fse_Size - (*fs2)->fse_Size);
- }
-
-
- static short DifferentType(const struct FSDirEntry *fs1, const struct FSDirEntry *fs2)
- {
- ASSERT_VALID(fs1);
- ASSERT_VALID(fs2);
-
- return (short) ((fs1->fse_Typ != fs2->fse_Typ) && (!isFile(fs1) || !isFile(fs2)));
- }
-
-
- static void FSSubDir(struct FSDirEntry *SubDirEntry)
- {
- char *NewDirName;
- struct FSDir *SubDir;
-
- if (isFile(SubDirEntry))
- return;
-
- SetFSHasSelects(aktFSDir);
-
- GetAttr(ALV_TopLine, FSGadgets[GDX_FSALVGadget], &aktFSDir->fsd_TopLine); // TopLine merken
-
- NewDirName = ConcatDirName(aktFSDir->fsd_Name, SubDirEntry->fse_Name);
-
- SubDir = SubDirEntry->fse_Contents;
- if (SubDir == NULL)
- SubDir = SearchFSDir(NewDirName);
-
- if (SubDir)
- {
- if (SubDir->fsd_isComplete)
- {
- // Directory bereits vollständig gelesen
- aktFSDir = SubDir;
- ReSortEntryList(aktFSDir);
- GT_SetGadgetAttrs(FSGadgets[GDX_FSDrawerGadget], FSwin, NULL,
- GTST_String, aktFSDir->fsd_Name,
- TAG_END);
- }
- else
- {
- // Directory schon einmal teilweise gelesen
- aktFSDir = ReadFSDir(SubDir->fsd_Name, SubDir, SubDirEntry);
- }
- }
- else
- {
- // Directory noch nie gelesen
- SubDirEntry->fse_Contents = GetFSDir(NewDirName, SubDirEntry);
-
- aktFSDir->fsd_ParentEntry = SubDirEntry;
- }
-
- free(NewDirName);
-
- aktFSDir->fsd_ParentSelected = aktFSDir->fsd_ParentSelected ||
- ST_Selected == SubDirEntry->fse_Selected;
-
- GT_SetGadgetAttrs(FSGadgets[GDX_FSParentGadget], FSwin, NULL,
- GA_Disabled, aktFSDir->fsd_isVolList,
- TAG_END);
- }
-
-
- static void FSParentDir(void)
- {
- struct FSDir *Child, *Parent;
- struct FSDirEntry *FSe;
- char *SubDirName;
-
- // Kein Parent bei der Volume-Liste
- if (aktFSDir->fsd_isVolList)
- return;
-
- SetFSHasSelects(aktFSDir);
-
- GetAttr(ALV_TopLine, FSGadgets[GDX_FSALVGadget], &aktFSDir->fsd_TopLine);
-
- Child = aktFSDir;
-
- if (aktFSDir->fsd_Name[strlen(aktFSDir->fsd_Name)-1] == ':')
- {
- // wir sind schon im Root Directory
- Parent = GetVolumes();
-
- GT_SetGadgetAttrs(FSGadgets[GDX_FSParentGadget], FSwin, NULL,
- GA_Disabled, TRUE,
- TAG_END);
- aktFSDir = Parent;
-
- SubDirName = Child->fsd_Name;
- DisplayFSList(aktFSDir);
- }
- else
- {
- Parent = aktFSDir =
- GetFSDir(FindParentName(Child->fsd_Name), NULL);
-
- SubDirName = Child->fsd_Name + strlen(Child->fsd_Name) - 1;
- while (SubDirName != Child->fsd_Name &&
- *SubDirName != '/' && *SubDirName != ':')
- SubDirName--;
-
- SubDirName++;
- }
-
- FSe = FindFSEntry(SubDirName, Parent);
- if (FSe)
- {
- short OldHasSelects;
-
- Child->fsd_ParentEntry = FSe;
- FSe->fse_Contents = Child;
- OldHasSelects = FSe->fse_HasSelects;
- FSe->fse_HasSelects = Child->fsd_HasSelects || ManualSelectCount(Child) > 0;
-
- if (OldHasSelects != FSe->fse_HasSelects)
- FindAndRedisplayDirEntry(Parent, FSe, 0, 0, RDM_ContentsChanged);
- }
-
- GT_SetGadgetAttrs(FSGadgets[GDX_FSDrawerGadget], FSwin, NULL,
- GTST_String, aktFSDir->fsd_Name,
- TAG_END);
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_TopLine, aktFSDir ? aktFSDir->fsd_TopLine : 0l,
- TAG_END);
- }
-
-
- // sucht nach allen Volumes im System
- static struct FSDir *GetVolumes(void)
- {
- struct FSDir *Dir, *LastDir;
- struct FSDirEntry *FSe = NULL;
- struct DosList *dlist;
- struct Process *myProcess;
- char *bname;
-
- SetBusyPointer(FSwin, TRUE);
-
- SetFSHasSelects(aktFSDir);
-
- Dir = SearchFSDir("");
-
- LastDir = Dir;
-
- Dir = MakeFSDir("", NULL); // Dir neu anlegen
- Dir->fsd_isVolList = TRUE;
-
- // keine Requester "Insert Volume XXX:" bei nicht gemounteten Volumes!
- myProcess = (struct Process *) FindTask(NULL);
- myProcess->pr_WindowPtr = (APTR) ~0;
-
- dlist = LockDosList(DOSLIST_FLAGS);
- dlist = NextDosEntry(dlist, DOSLIST_FLAGS);
- while (dlist)
- {
- BPTR DLLock;
-
- bname = btocstr(dlist->dol_Name);
-
- switch (dlist->dol_Type)
- {
- case DLT_DEVICE:
- if (dlist->dol_misc.dol_handler.dol_Startup)
- {
- struct FileSysStartupMsg *Startup;
- struct DosEnvec *env;
-
- Startup = (struct FileSysStartupMsg *) BADDR(dlist->dol_misc.dol_handler.dol_Startup);
- if (Startup != NULL && (TypeOfMem(Startup) != 0L ||inROM((APTR) Startup)))
- env = (struct DosEnvec *) BADDR(Startup->fssm_Environ);
- else
- env = NULL;
-
- if (env != NULL && (TypeOfMem(env) != 0L ||inROM((APTR) env)))
- {
- FSe = NewFSEntry(bname, Device);
- FSe->fse_eInfo = env;
- FSe->fse_Size = (1 + env->de_HighCyl - env->de_LowCyl)
- * env->de_Surfaces * env->de_BlocksPerTrack
- * (env->de_SizeBlock << 2); // Größe in Bytes
-
- }
- else if (FSe)
- {
- DestroyFSEntry(&FSe);
- }
- }
- else
- FSe = NULL;
- break;
-
- case DLT_VOLUME:
- FSe = NewFSEntry(bname, Volume);
- FSe->fse_Date = dlist->dol_misc.dol_volume.dol_VolumeDate;
- break;
-
- default:
- FSe = NewFSEntry(bname, Assign);
- break;
- }
-
- if (FSe)
- {
- if (dlist->dol_Type == DLT_DEVICE)
- {
- FSe->fse_HasSelects = 0;
-
- if (Dir->fsd_DirCount >= Dir->fsd_ListSize)
- ExtendFSDir(Dir);
-
- Dir->fsd_EntryList[Dir->fsd_DirCount] = FSe;
- ++Dir->fsd_DirCount;
-
- DuplicateOldEntry(Dir, LastDir, FSe);
- }
- else
- {
- DLLock = Lock(FSe->fse_Name, ACCESS_READ);
- if (NULL == DLLock)
- {
- DestroyFSEntry(&FSe);
- }
- else
- {
- FSe->fse_HasSelects = LookUpFSDir(Dir->fsd_Name, FSe->fse_Name);
-
- if (Dir->fsd_DirCount >= Dir->fsd_ListSize)
- ExtendFSDir(Dir);
-
- Dir->fsd_EntryList[Dir->fsd_DirCount] = FSe;
- ++Dir->fsd_DirCount;
-
- DuplicateOldEntry(Dir, LastDir, FSe);
-
- UnLock(DLLock);
- }
- }
- }
-
- dlist = NextDosEntry(dlist, DOSLIST_FLAGS);
- }
- UnLockDosList(DOSLIST_FLAGS);
-
- myProcess->pr_WindowPtr = NULL;
-
- if (LastDir)
- RemoveFSDir(LastDir);
-
- Dir->fsd_isComplete = TRUE;
- SetFSDirListSize(Dir, Dir->fsd_DirCount + 2);
- SortFSList(Dir);
-
- SetBusyPointer(FSwin, FALSE);
-
- return Dir;
- }
-
-
- static void DuplicateOldEntry(struct FSDir *Dir, struct FSDir *OldDir,
- struct FSDirEntry *FSe)
- {
- struct FSDirEntry *FSold;
-
- if (OldDir && (FSold = FindFSEntry(FSe->fse_Name, OldDir)))
- {
- // Einträge aus altem Directory übernehmen
- ASSERT_VALID(Dir);
- ASSERT_VALID(FSe);
-
- if (ST_Selected == FSold->fse_Selected)
- SelectDirEntry(Dir, Dir->fsd_DirCount-1, FSold->fse_ManualSelect != ST_None);
-
- FSe->fse_HasSelects = FSold->fse_HasSelects;
-
- // Zeiger auf ParentEntry und ParentDir korrigieren
- if (FSe->fse_Contents = FSold->fse_Contents)
- {
- FSe->fse_Contents->fsd_ParentEntry = FSe;
- }
- }
- }
-
-
- static char *GetFullPathName(BPTR FileLock)
- {
- char *result = NULL;
- char *NBuff;
-
- ASSERT_VALID(BADDR(FileLock));
-
- NBuff = malloc(512);
- if (NULL == NBuff)
- return NULL;
-
- if (NameFromLock(FileLock, NBuff, 512))
- result = NBuff;
- else
- free(NBuff);
-
- return result;
- }
-
-
- static void ReSortEntryList(struct FSDir *Dir)
- {
- ASSERT_VALID(Dir);
-
- SortFSList(Dir);
- }
-
-
- // Suche im Directory <Dir> nach einem Eintrag mit dem Namen <Name>. Liefert
- // den gefundenen FSDirEntry zurück oder NULL
- static struct FSDirEntry *FindFSEntry(const char *Name, struct FSDir *Dir)
- {
- short n, found;
- struct FSDirEntry **FSe, *FSfound;
-
- ASSERT_VALID(Name);
- ASSERT_VALID(Dir);
-
- found = FALSE;
- FSfound = NULL;
- for (n=0, FSe=Dir->fsd_EntryList; !found && n<Dir->fsd_DirCount; n++, FSe++)
- {
- found = stricmp(Name, (*FSe)->fse_Name) == 0;
- if (found)
- FSfound = *FSe;
- }
-
- return FSfound;
- }
-
-
- void SelectFSEntry(struct FSDir *Dir, struct FSDirEntry *FSe)
- {
- unsigned short n;
- short found;
-
- ASSERT_VALID(Dir);
- ASSERT_VALID(FSe);
-
- for (n=0, found=FALSE; !found && n<Dir->fsd_DirCount; )
- {
- found = Dir->fsd_EntryList[n] == FSe;
- if (!found)
- n++;
- }
-
- if (found)
- {
- SelectDirEntry(Dir, n, TRUE);
-
- if (Dir->fsd_ParentEntry)
- Dir->fsd_ParentEntry->fse_HasSelects = ManualSelectCount(Dir) > 0;
- }
- }
-
-
- static void SelectDirEntry(struct FSDir *Dir, short n, BOOL Manual)
- {
- ASSERT_VALID(Dir);
-
- InternalSelectEntry(Dir, Dir->fsd_EntryList[n], TRUE, Manual, 0, TRUE);
- }
-
-
- static void DeselectDirEntry(struct FSDir *Dir, short n, BOOL Manual)
- {
- ASSERT_VALID(Dir);
-
- InternalSelectEntry(Dir, Dir->fsd_EntryList[n], FALSE, Manual, 0, TRUE);
- }
-
-
- static void InternalSelectEntry(struct FSDir *Dir, struct FSDirEntry *FSe,
- BOOL Select, BOOL Manual, short Level, BOOL Recursive)
- {
- struct ALVRecordChange RecordChange;
- BOOL PrevHasSelects;
- BOOL FSeIsFile;
-
- PrevHasSelects = FSe->fse_HasSelects;
- FSeIsFile = isFile(FSe);
-
- if ( !Select && ST_Selected == FSe->fse_Selected)
- {
- // Deselektieren
- FSe->fse_Selected = ST_Deselected;
-
- FSe->fse_fsRecord.alr_Flags &= ~ALRF_SELECTED;
-
- Dir->fsd_SelectCount--;
-
- if (FSeIsFile)
- {
- if (Manual)
- {
- if (ST_Selected == FSe->fse_ManualSelect)
- FSFileSelectCount--;
-
- FSe->fse_ManualSelect = Dir->fsd_ParentSelected ? ST_Deselected : ST_None;
- }
- }
- else
- {
- if (Manual)
- {
- if (ST_Selected == FSe->fse_ManualSelect)
- FSDirSelectCount--;
-
- FSe->fse_ManualSelect = Dir->fsd_ParentSelected ? ST_Deselected : ST_None;
- }
-
- if (Recursive)
- SelectChildEntry(Dir, FSe, Level);
- }
- }
- else if (Select && FSe->fse_Selected != ST_Selected )
- {
- // Selektieren
- FSe->fse_Selected = ST_Selected;
-
- FSe->fse_fsRecord.alr_Flags |= ALRF_SELECTED;
-
- Dir->fsd_SelectCount++;
-
- if (Manual)
- {
- FSe->fse_ManualSelect = !Dir->fsd_ParentSelected ? ST_Selected : ST_None;
- }
-
- if (FSeIsFile)
- {
- if (Manual)
- FSFileSelectCount++;
- }
- else
- {
- struct FSDir *SelectedDir;
-
- if (Manual)
- FSDirSelectCount++;
-
- SelectedDir = CreateFSDir(ConcatDirName(Dir->fsd_Name, FSe->fse_Name), NULL);
- SelectedDir->fsd_ParentSelected = TRUE;
- if (SelectedDir->fsd_DirCount == 0)
- SelectedDir->fsd_isComplete = FALSE;
-
- if (Recursive)
- SelectChildEntry(Dir, FSe, Level);
- }
- }
-
- if (Dir->fsd_ParentEntry)
- Dir->fsd_ParentEntry->fse_HasSelects = ManualSelectCount(Dir) > 0;
-
- if (PrevHasSelects != FSe->fse_HasSelects)
- {
- // <HasSelects> hat sich geändert: Anzeige aktualisieren
- FindAndRedisplayDirEntry(Dir, FSe, 0, 0, RDM_ContentsChanged);
- }
-
- if (!FSeIsFile)
- {
- // Anzeige des Select-Marker aktualisieren
- RecordChange.arc_FirstRecord = &FSe->fse_fsRecord;
- RecordChange.arc_RecordCount = 1;
- RecordChange.arc_FirstColumnNo = 0;
- RecordChange.arc_LastColumnNo = 0;
- RecordChange.arc_ContentsChanged = FALSE;
-
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_InvalidateRecords, &RecordChange,
- TAG_END);
- }
- }
-
-
- long ManualSelectCount(struct FSDir *Dir)
- {
- long Result = 0;
- unsigned long n;
-
- if (Dir == NULL)
- return 0;
-
- for (n=0; n<Dir->fsd_DirCount; n++)
- {
- if (Dir->fsd_EntryList[n]->fse_ManualSelect != ST_None)
- Result++;
- }
-
- return Result;
- }
-
-
- static void SelectChildEntry(struct FSDir *Dir, struct FSDirEntry *FSe, short Level)
- {
- unsigned long m;
- char FullName[FMSIZE];
- char *NormalizedName;
- struct FSDir *SubDir;
- unsigned long index = 0l;
-
- if (Level >= 1 && !BackupOpt->bo_IncludeSubDirs)
- return;
-
- NormalizedName = NormalizeName(ConcatDirName(Dir->fsd_Name, FSe->fse_Name));
- if (NULL == NormalizedName)
- return;
-
- stccpy(FullName, NormalizedName, sizeof(FullName));
- free(NormalizedName);
-
- if (FSe->fse_Contents == NULL)
- SubDir = LookUpSubDir(FullName, &index);
- else
- SubDir = FSe->fse_Contents;
-
- do {
- if (SubDir == NULL)
- continue;
-
- SubDir->fsd_ParentSelected = FSe->fse_Selected == ST_Selected;
-
- for (m=0; m<SubDir->fsd_DirCount; m++)
- {
- if (SubDir->fsd_EntryList[m]->fse_ManualSelect == ST_None &&
- FSFileMatch(BackupOpt, SubDir->fsd_EntryList[m]))
- {
- // Da durch die do {} Schleife bereits ALLE Subdirectories
- // durchgegangen werden, wird hier NICHT REKURSIV Selektiert !
- InternalSelectEntry(SubDir, SubDir->fsd_EntryList[m],
- FSe->fse_Selected == ST_Selected,
- FALSE, Level+1, FALSE);
- }
- }
-
- SetFSHasSelects(SubDir);
-
- if (SubDir == aktFSDir)
- {
- DisplayFSList(aktFSDir);
- }
-
- SubDir = LookUpSubDir(FullName, &index);
- } while (SubDir);
- }
-
-
- // mit String-Operationen wird der Name des Parent Directory aus <DirName> ermittelt.
- static char *FindParentName(char *DirName)
- {
- char *Trenn;
-
- ASSERT_VALID(DirName);
- DirName = strdup(DirName);
- if (DirName == NULL)
- {
- alarm(GetString(MSG_OUTOFMEMORY), __FUNC__, "DirName", strlen(DirName));
- myabort(10);
- }
-
- if (strlen(DirName) < 2)
- {
- *DirName = '\0';
- return DirName;
- }
-
- Trenn = DirName + strlen(DirName) - 2; // auf vorletztes Zeichen zeigen
- while (Trenn != DirName && *Trenn != ':' && *Trenn != '/')
- Trenn--;
-
- if (Trenn == DirName)
- {
- *DirName = '\0';
- return DirName;
- }
-
- if (*Trenn == '/')
- *Trenn = '\0';
- else
- Trenn[1] = '\0';
-
- return DirName;
- }
-
-
- static void SelectFSAttr(BOOL Select)
- {
- struct FileInfoBlock __aligned fib;
- struct ALVRecordChange RecordChange;
- long fromDate, toDate;
- short found, n;
-
- GetPatternGadgetString();
-
- fromDate = ReadDate(GADSTRING(FSGadgets[GDX_FSFromDateGadget]));
- toDate = ReadDate(GADSTRING(FSGadgets[GDX_FSToDateGadget]));
-
- if (BackupOpt->bo_UseGrepPattern && !SelectPattern.isParsed)
- {
- if (ParsePatternNoCase(SelectPattern.RawName,
- SelectPattern.ParsedPattern,
- sizeof(SelectPattern.ParsedPattern) ) == -1)
- {
- alarm("%s: %s", __FUNC__, GetString(MSG_XLATEERROR_SELECT));
- SelectPattern.isParsed = FALSE;
- }
- else
- SelectPattern.isParsed = TRUE;
- }
-
- for (n=0; n<aktFSDir->fsd_DirCount; n++)
- {
- // wahlweise mit eigenem PatternMatch (*,?) oder mit dem
- // besseren PatternMatcher des DOS2.0 arbeiten
- if (BackupOpt->bo_UseGrepPattern && SelectPattern.isParsed)
- {
- found = MatchPatternNoCase(SelectPattern.ParsedPattern,
- aktFSDir->fsd_EntryList[n]->fse_Name);
- }
- else
- {
- stccpy(fib.fib_FileName, aktFSDir->fsd_EntryList[n]->fse_Name,
- sizeof(fib.fib_FileName)-1);
- found = FileNamePatternMatch(SelectPattern.RawName, &fib);
- }
-
- // nach Archiv-Bit
- switch (FSArchiveSelect)
- {
- case ARCSEL_Cleared:
- found = found && !(aktFSDir->fsd_EntryList[n]->fse_Protection & FIBF_ARCHIVE);
- break;
- case ARCSEL_Set:
- found = found && (aktFSDir->fsd_EntryList[n]->fse_Protection & FIBF_ARCHIVE);
- break;
- }
-
- // nach Datum
- found = found
- && (aktFSDir->fsd_EntryList[n]->fse_Date.ds_Days >= fromDate
- || !(FSGadgets[GDX_FSFromOnGadget]->Flags & GFLG_SELECTED))
- && (aktFSDir->fsd_EntryList[n]->fse_Date.ds_Days < toDate
- || !(FSGadgets[GDX_FSToOnGadget]->Flags & GFLG_SELECTED));
-
- if (found)
- {
- if (Select)
- SelectDirEntry(aktFSDir, n, TRUE);
- else
- DeselectDirEntry(aktFSDir, n, TRUE);
- }
- }
-
- if (aktFSDir->fsd_ParentEntry)
- aktFSDir->fsd_ParentEntry->fse_HasSelects = ManualSelectCount(aktFSDir) > 0;
-
- GetAttr(ALV_Records, FSGadgets[GDX_FSALVGadget], (ULONG *) &RecordChange.arc_FirstRecord);
- RecordChange.arc_RecordCount = ULONG_MAX;
- RecordChange.arc_FirstColumnNo = 0;
- RecordChange.arc_LastColumnNo = ULONG_MAX;
- RecordChange.arc_ContentsChanged = FALSE;
-
- SetGadgetAttrs(FSGadgets[GDX_FSALVGadget], FSwin, NULL,
- ALV_InvalidateRecords, &RecordChange,
- TAG_END);
- }
-
-
- // aus den beiden Namensteilen <ParentName> und <DirName> wird ein gültiger Pfadname erzeugt.
- char *ConcatDirName(const char *ParentName, char *DirName)
- {
- size_t len;
- char *NewDirName;
-
- ASSERT_VALID(ParentName);
- ASSERT_VALID(DirName);
-
- len = strlen(ParentName) + strlen(DirName) + 3;
- NewDirName = malloc(len);
- if (NewDirName == NULL)
- {
- alarm(GetString(MSG_OUTOFMEMORY), __FUNC__, "NewDirName", len);
- myabort(10);
- }
-
- strcpy(NewDirName, ParentName);
- AddPart(NewDirName, DirName, len);
-
- return NewDirName;
- }
-
-
- /* Suche, ob das Subdirectory <DirName> im Directory <ParentName>
- oder irgendwelche Subdirectories von <DirName> bereits
- in BackupOpt->bo_FSDirList eingetragen sind.
- Werden Einträge gefunden, wird nach den HasSelects geschaut.
- Liefert TRUE zurück, wenn irgendwelche Subdirectories mit HasSelects != 0
- gefunden wurden, sonst FALSE.
- */
- static BOOL LookUpFSDir(char *ParentName, char *DirName)
- {
- char *ccParentName, *FullParentName;
- struct FSDir **dir;
- unsigned long n;
- BOOL result=FALSE;
-
- ASSERT_VALID(ParentName);
- ASSERT_VALID(DirName);
-
- ccParentName = ConcatDirName(ParentName, DirName);
- FullParentName = NormalizeName(ccParentName);
-
- for (n=0, dir=BackupOpt->bo_FSDirList; !result && n<BackupOpt->bo_FSDirCount; n++, dir++)
- {
- if (isChildOf(FullParentName, (*dir)->fsd_Name))
- result |= (*dir)->fsd_HasSelects || ManualSelectCount(*dir);
- }
-
- free(FullParentName);
- free(ccParentName);
-
- return result;
- }
-
-
- /* Suche, ob das Directory <DirName>
- oder irgendwelche Subdirectories von <DirName> bereits
- in BackupOpt->bo_FSDirList eingetragen sind.
- Liefert den Eintrag zurück, wenn irgendwelche Subdirectories
- gefunden wurden, sonst FALSE.
- */
- static struct FSDir *LookUpSubDir(char *ParentName, unsigned long *n)
- {
- struct FSDir **dir;
- short found;
-
- ASSERT_VALID(ParentName);
-
- for (found=FALSE, dir=&BackupOpt->bo_FSDirList[*n]; !found && *n<BackupOpt->bo_FSDirCount; (*n)++)
- {
- found = stricmp(ParentName, (*dir)->fsd_Name) == 0 ||
- isChildOf(ParentName, (*dir)->fsd_Name);
-
- if (!found)
- dir++;
- }
-
- return found ? (*dir) : NULL;
- }
-
-
- /* Suche, ob irgendwelche Parent Directories von <DirName> bereits
- in BackupOpt->bo_FSDirList eingetragen sind.
- Liefert den passenden Eintrag zurück, wenn irgendwelche
- Parent Directories gefunden wurden, sonst NULL.
- */
- static struct FSDir *LookUpParentDir(const char *SubDirName, unsigned long *n)
- {
- struct FSDir **dir;
- BOOL found;
-
- ASSERT_VALID(SubDirName);
-
- for (found=FALSE,dir=&BackupOpt->bo_FSDirList[*n]; !found &&
- (*n)<BackupOpt->bo_FSDirCount; (*n)++)
- {
- found = isChildOf((*dir)->fsd_Name, SubDirName);
-
- if (!found)
- dir++;
- }
-
- return found ? *dir : NULL;
- }
-
-
- // Suchen in BackupOpt->bo_FSDirList nach Directory <DirName>
- struct FSDir *SearchFSDir(const char *DirName)
- {
- struct FSDir **dir;
- short found;
- unsigned long n;
-
- ASSERT_VALID(DirName);
-
- for (n=0, dir=BackupOpt->bo_FSDirList, found=0; !found && n<BackupOpt->bo_FSDirCount; n++)
- {
- found = stricmp(DirName, (*dir)->fsd_Name) == 0;
- if (!found)
- dir++;
- }
-
- return found ? *dir : NULL;
- }
-
-
- static void EmptyFSDir(struct FSDir *dir)
- {
- unsigned long n;
-
- ASSERT_VALID(dir);
-
- for (n=0; n<dir->fsd_DirCount; n++)
- {
- DestroyFSEntry(&dir->fsd_EntryList[n]);
- }
-
- dir->fsd_DirCount = 0;
- dir->fsd_SelectCount = 0;
- }
-
-
- /* Alle Einträge im Directory <Dir> prüfen, ob HasSelects dort gesetzt ist,
- und entsprechend Dir->fse_HasSelects setzen.
- */
- static short SetFSHasSelects(struct FSDir *Dir)
- {
- unsigned long n;
-
- ASSERT_VALID(Dir);
- Dir->fsd_HasSelects = FALSE;
-
- for (n=0; !Dir->fsd_HasSelects && n<Dir->fsd_DirCount; n++)
- {
- struct FSDirEntry *FSe;
-
- FSe = Dir->fsd_EntryList[n];
-
- // hier werden manuelle Selekts aufgehoben, wenn sie mit dem ParentSelect übereinstimmen
- if (Dir->fsd_ParentSelected)
- {
- if (ST_Selected == FSe->fse_ManualSelect)
- FSe->fse_ManualSelect = ST_None;
- }
- else
- {
- if (ST_Deselected == FSe->fse_ManualSelect)
- FSe->fse_ManualSelect = ST_None;
- }
-
- if (!isFile(FSe))
- {
- // Volume oder Directory
- Dir->fsd_HasSelects |= FSe->fse_HasSelects;
- }
- }
-
- return (short) Dir->fsd_HasSelects;
- }
-
-
- static BOOL isleap(short year)
- {
- return (BOOL)(((year % 4) == 0) && ((year % 100) != 0 || (year % 400) == 0));
- }
-
-
- char *GetFileFlags(long Flags)
- {
- static char prot[9];
- static const char protnames[] = "hsparwed";
- short i;
-
- Flags ^= 0x0f;
- for (i=0; i<strlen(protnames); i++)
- prot[i] = (Flags & (0x80 >> i)) ? protnames[i] : '-';
- prot[i] = '\0';
-
- return prot;
- }
-
-
- // vertauscht den Inhalt der String-Gadgets <Gad1> und <Gad2>
- void SwapFromToDate(struct Window *Win, struct Gadget *Gad1, struct Gadget *Gad2)
- {
- char *tempFrom, *tempTo;
-
- ASSERT_VALID(Win);
- ASSERT_VALID(Gad1);
- ASSERT_VALID(Gad2);
-
- tempFrom = strdup(GADSTRING(Gad1));
- if (tempFrom == NULL)
- return;
-
- tempTo = strdup(GADSTRING(Gad2));
- if (tempTo == NULL)
- {
- free(tempFrom);
- return;
- }
-
- GT_SetGadgetAttrs(Gad1, Win, NULL,
- GTST_String, tempTo,
- TAG_END);
- GT_SetGadgetAttrs(Gad2, Win, NULL,
- GTST_String, tempFrom,
- TAG_END);
-
- free(tempFrom);
- free(tempTo);
- }
-
-
- // Einstellung aller Gadgets für die Sicherung ahand der Werte in <NewOpts>
- static void SetupBackupOpts(struct BackupOptions *NewOpts, const char *NewCmdFileName)
- {
- struct myDate date;
-
- ASSERT_VALID(NewOpts);
- ASSERT_VALID(NewCmdFileName);
-
- strcpy(CmdFileName, NewCmdFileName);
-
- // Datums-Strings vorbelegen
- UnpackDate(NewOpts->bo_FirstDate, &date);
- GT_SetGadgetAttrs(FSGadgets[GDX_FSFromDateGadget], FSwin, NULL,
- GTST_String, DateString(date.Day, date.Month, date.Year),
- TAG_END);
-
- UnpackDate(NewOpts->bo_LastDate, &date);
- GT_SetGadgetAttrs(FSGadgets[GDX_FSToDateGadget], FSwin, NULL,
- GTST_String, DateString(date.Day, date.Month, date.Year),
- TAG_END);
-
- ShowWildcardOpt(NewOpts);
- TranslateWildCards(NewOpts);
- SetMenus(NewOpts);
- }
-
-
- static void DisplaySelectCount(void)
- {
- static unsigned long LastFileSelectCount = ~0;
- static unsigned long LastDirSelectCount = ~0;
- static char WinTitle[100];
-
- if (LastFileSelectCount != FSFileSelectCount ||
- LastDirSelectCount != FSDirSelectCount)
- {
- sprintf(WinTitle,
- GetString(MSG_FSWIN_TITLE),
- FSDirSelectCount,
- GetString(FSDirSelectCount == 1 ? MSG_FSWIN_TITLE_DIR1 : MSG_FSWIN_TITLE_DIR2),
- FSFileSelectCount,
- GetString(FSFileSelectCount == 1 ? MSG_FSWIN_TITLE_FILE1 : MSG_FSWIN_TITLE_FILE2)
- );
-
- SetWindowTitles(FSwin, WinTitle, (UBYTE *) ~0);
-
- LastFileSelectCount = FSFileSelectCount;
- LastDirSelectCount = FSDirSelectCount;
- }
-
- // Start-Gadget disabled wenn nichts selektiert
- GT_SetGadgetAttrs(FSGadgets[GDX_FSStartGadget], FSwin, NULL,
- GA_Disabled, 0 == (FSFileSelectCount + FSDirSelectCount),
- TAG_END);
- }
-
-
- void TranslateWildCards(struct BackupOptions *BackupOpt)
- {
- if (BackupOpt->bo_UseGrepPattern)
- {
- if (strcmp(SelectPattern.RawName, "*") == 0)
- strcpy(SelectPattern.RawName, "#?");
-
- if (strcmp(BackupOpt->bo_IncludeFile.RawName, "*") == 0)
- strcpy(BackupOpt->bo_IncludeFile.RawName, "#?");
- if (strcmp(BackupOpt->bo_ExcludeFile.RawName, "*") == 0)
- strcpy(BackupOpt->bo_ExcludeFile.RawName, "#?");
- }
- else
- {
- if (strcmp(SelectPattern.RawName, "#?") == 0)
- strcpy(SelectPattern.RawName, "*");
-
- if (strcmp(BackupOpt->bo_IncludeFile.RawName, "#?") == 0)
- strcpy(BackupOpt->bo_IncludeFile.RawName, "*");
- if (strcmp(BackupOpt->bo_ExcludeFile.RawName, "#?") == 0)
- strcpy(BackupOpt->bo_ExcludeFile.RawName, "*");
- }
-
- if (FSGadgets)
- {
- GT_SetGadgetAttrs(FSGadgets[GDX_FSPatternGadget], FSwin, NULL,
- GTST_String, SelectPattern.RawName,
- TAG_END);
- }
-
- SelectPattern.isParsed = FALSE;
- BackupOpt->bo_IncludeFile.isParsed = FALSE;
- BackupOpt->bo_ExcludeFile.isParsed = FALSE;
- }
-
-
- static void EnableGOGadget(void)
- {
- if (FSwin)
- {
- GT_SetGadgetAttrs(FSGadgets[GDX_FSGlobOptGadget], FSwin, NULL,
- GA_Disabled, FALSE,
- TAG_END);
- }
- }
-
-
- static short isFile(const struct FSDirEntry *FS)
- {
- short result;
-
- ASSERT_VALID(FS);
-
- switch (FS->fse_Typ)
- {
- case File:
- case HardLinkFile:
- case SoftLinkFile:
- case Device:
- result = TRUE;
- break;
- case Directory:
- case Assign:
- case Volume:
- case SoftLinkDir:
- case HardLinkDir:
- result = FALSE;
- break;
- }
-
- return result;
- }
-
-
- /* Untersuchen, ob ein SoftLink zu einem Directory oder einem File gehört.
- Liefert je nachdem "SoftLinkFile" oder "SoftLinkDir" zurück.
- kann getrost DOS V37+ Funktionen benutzen, da bei älteren Funktionen
- sowieso keine SoftLinks erkannt werden.
- */
- enum FType SoftLinkType(const STRPTR Name, BPTR DirLock)
- {
- static struct FileInfoBlock __aligned SLfib;
-
- ASSERT_VALID(Name);
- ASSERT_VALID(BADDR(DirLock));
-
- if (!ResolveSoftLink(Name, DirLock, &SLfib))
- return SoftLinkDir;
- else
- return SLfib.fib_DirEntryType >= 0 ? SoftLinkDir : SoftLinkFile;
- }
-
-
- // Auflösen eines SoftLinks - wenn nötig rekursiv
- short ResolveSoftLink(const STRPTR LinkName, BPTR DirLock, struct FileInfoBlock *LinkFib)
- {
- char SoftLinkPath[FMSIZE];
- char PathName[FMSIZE];
- BPTR SLock;
-
- ASSERT_VALID(LinkName);
- ASSERT_VALID(BADDR(DirLock));
- ASSERT_VALID(LinkFib);
-
- if (!NameFromLock(DirLock, PathName, sizeof(PathName)))
- {
- PostError(TRUE, MSGPRI_Error, GetString(MSG_NAMEFROMLOCK_FAILED_RSL), PathName);
- return FALSE;
- }
-
- do {
- if (!ReadLink(DeviceProc(PathName), DirLock,
- (STRPTR) LinkName, SoftLinkPath, sizeof(SoftLinkPath)) )
- {
- PostError(TRUE, MSGPRI_Error, GetString(MSG_READLINK_FAILED_RSL), SoftLinkPath);
-
- return FALSE;
- }
- SLock = Lock(SoftLinkPath, ACCESS_READ);
- Examine(SLock, LinkFib);
- UnLock(SLock);
-
- strcpy(PathName, SoftLinkPath);
- } while (LinkFib->fib_DirEntryType == ST_SOFTLINK);
-
- return TRUE;
- }
-
-
- void LoadCmdFile(struct Window *Win, char *LoadCmdFileName,
- struct BackupOptions *Opt)
- {
- struct FSDir **Dir;
- char *path;
- unsigned long n, m;
- short Ok;
-
- ASSERT_VALID(Win);
- ASSERT_VALID(LoadCmdFileName);
- ASSERT_VALID(Opt);
-
- // Alle Einträge deselektieren
- for (n=0, Dir=Opt->bo_FSDirList; n<Opt->bo_FSDirCount; n++, Dir++)
- {
- for (m=0; m<(*Dir)->fsd_DirCount; m++)
- {
- DeselectDirEntry(*Dir, m, TRUE);
- (*Dir)->fsd_EntryList[m]->fse_HasSelects = FALSE;
- }
- (*Dir)->fsd_SelectCount = 0;
- (*Dir)->fsd_HasSelects = FALSE;
- }
-
- DefaultOptions(Opt, 0); // alles auf default-Werte
-
- // ggf. Argumente aus .info übernehmen
- Ok = CheckDiskObject(LoadCmdFileName, Opt);
-
- if (Ok && OpenCmdFile(LoadCmdFileName))
- {
- do {
- path = ReadCmdFile(Opt, 0);
- } while (path);
-
- CloseCmdFile();
- RefreshXGO(Opt);
- }
-
- SetupBackupOpts(Opt, LoadCmdFileName);
- DisplaySelectCount();
- }
-
-
- // Icon wurde im FS-Window oder im GO-Window fallengelassen
- static void UseDiskObject(struct AppMessage *AppMsg)
- {
- unsigned long n;
-
- ASSERT_VALID(AppMsg);
-
- if (AppMsg->am_ID == AMID_FILESELECT && isInFileView(AppMsg->am_MouseX, AppMsg->am_MouseY))
- {
- // Drop innerhalb des File-Window
- AddFSEntries(AppMsg);
- }
- else
- {
- // Drop im GO-Window oder außerhalb des File-Window => Kommandofile
- ClearSettings(FALSE);
-
- n = AppMsg->am_NumArgs; // Anzahl Argumente
-
- if (n > 0)
- {
- BPTR OldLock;
- short Ok;
-
- OldLock = CurrentDir(DupLock(AppMsg->am_ArgList[0].wa_Lock));
-
- Ok = CheckDiskObject(AppMsg->am_ArgList[0].wa_Name, BackupOpt);
-
- if (Ok && OpenCmdFile(AppMsg->am_ArgList[0].wa_Name))
- {
- char *path;
- BPTR CmdFileLock;
-
- // Name des geladenen Kommandofiles merken
- CmdFileLock = Lock(AppMsg->am_ArgList[0].wa_Name, ACCESS_READ);
- if (CmdFileLock)
- {
- NameFromLock(CmdFileLock, CmdFileName, sizeof(CmdFileName));
-
- // Pfad des Kommandofiles in <BackupOpt->bo_ScriptPath> übernehmen
- stcgfp(BackupOpt->bo_ScriptPath, CmdFileName);
- AddPart(BackupOpt->bo_ScriptPath, (STRPTR) "", sizeof(BackupOpt->bo_ScriptPath));
-
- UnLock(CmdFileLock);
- }
- else
- stccpy(CmdFileName, AppMsg->am_ArgList[0].wa_Name,
- sizeof(CmdFileName));
-
-
- do {
- path = ReadCmdFile(BackupOpt, 0);
- } while (path);
-
- CloseCmdFile();
- RefreshXGO(BackupOpt);
- }
- UnLock(CurrentDir(OldLock)); // Current Dir restaurieren
- }
- SetupBackupOpts(BackupOpt, CmdFileName);
- }
- DisplaySelectCount();
- }
-
-
- void ClearSettings(BOOL Show)
- {
- struct FSDir **Dir;
- short m, n;
-
- strcpy(CmdFileName, ""); // kein Kommandofile
-
- // Alle Einträge deselektieren
- for (n=0, Dir=BackupOpt->bo_FSDirList; n<BackupOpt->bo_FSDirCount; n++, Dir++)
- {
- for (m=0; m<(*Dir)->fsd_DirCount; m++)
- {
- struct FSDirEntry *FSe;
- BOOL OldSelect, OldHasSelects;
-
- FSe = (*Dir)->fsd_EntryList[m];
-
- OldSelect = FSe->fse_Selected;
- OldHasSelects = FSe->fse_HasSelects;
-
- DeselectDirEntry(*Dir, m, FALSE);
-
- FSe->fse_HasSelects = FALSE;
- FSe->fse_ManualSelect = ST_None;
-
- // Anzeige aktualisieren
- if (OldHasSelects != FSe->fse_HasSelects)
- FindAndRedisplayDirEntry(*Dir, FSe, 0, 0, RDM_ContentsChanged);
- if (OldSelect != FSe->fse_Selected)
- FindAndRedisplayDirEntry(*Dir, FSe, 0, ULONG_MAX, RDM_FlagsChanged);
- }
- (*Dir)->fsd_SelectCount = 0;
- (*Dir)->fsd_HasSelects = FALSE;
- }
-
- FSFileSelectCount = 0l;
- FSDirSelectCount = 0l;
-
- DefaultOptions(BackupOpt, 0); // alles auf default-Werte
-
- if (Show)
- {
- RefreshXGO(BackupOpt);
- DisplaySelectCount();
- }
- }
-
-
- static void AddFSEntries(struct AppMessage *AppMsg)
- {
- static struct FileInfoBlock __aligned fib;
- char DirName[FMSIZE];
- struct FSDir *Dir, **pDir;
- struct FSDirEntry *FSe;
- BPTR OldLock, FileLock;
- long m, n;
-
- ASSERT_VALID(AppMsg);
-
- for (n=0; n<AppMsg->am_NumArgs; n++)
- {
- OldLock = CurrentDir(DupLock(AppMsg->am_ArgList[n].wa_Lock));
-
- FileLock = Lock(AppMsg->am_ArgList[n].wa_Name, ACCESS_READ);
- if (!FileLock)
- {
- alarm(GetString(MSG_LOCK_FAILURE), __FUNC__,
- ShortFileName(AppMsg->am_ArgList[n].wa_Name, 60), GetIoErrText() );
- break;
- }
- Examine(FileLock, &fib);
- if (!NameFromLock(AppMsg->am_ArgList[n].wa_Lock, DirName, sizeof(DirName)))
- {
- alarm(GetString(MSG_NAMEFROMLOCK_FAILURE),
- ShortFileName(AppMsg->am_ArgList[n].wa_Name, 60),
- GetIoErrText() );
- break;
- }
- if (AppMsg->am_ArgList[n].wa_Name[0])
- {
- Dir = CreateFSDir(DirName, NULL);
- FSe = AddFSEntry(Dir, AppMsg->am_ArgList[n].wa_Name, GetFibType(fib.fib_EntryType, fib.fib_FileName, AppMsg->am_ArgList[n].wa_Lock));
- }
- else
- {
- char *ParentName;
-
- ParentName = FindParentName(DirName);
- Dir = CreateFSDir(ParentName, NULL);
- FSe = AddFSEntry(Dir, NurName(DirName), GetFibType(fib.fib_EntryType, fib.fib_FileName, AppMsg->am_ArgList[n].wa_Lock));
- free(ParentName);
- }
-
- SelectFSEntry(Dir, FSe);
- FindAndRedisplayDirEntry(Dir, FSe, 0l, ULONG_MAX, RDM_FlagsChanged);
-
- if (OldLock)
- UnLock(CurrentDir(OldLock)); // Current Dir restaurieren
- if (FileLock)
- UnLock(FileLock);
- }
-
- // Jetzt überall die <HasSelects> korrigieren
- for (n=0, pDir=BackupOpt->bo_FSDirList; n<BackupOpt->bo_FSDirCount; n++, pDir++)
- {
- for (m=0; m<(*pDir)->fsd_DirCount; m++)
- {
- FSe = (*pDir)->fsd_EntryList[m];
-
- if (!isFile(FSe))
- {
- short OldHasSelects;
-
- OldHasSelects = FSe->fse_HasSelects;
- FSe->fse_HasSelects = LookUpFSDir((*pDir)->fsd_Name, FSe->fse_Name);
-
- // sichtbare Änderungen sofort anzeigen
- if (OldHasSelects != FSe->fse_HasSelects)
- FindAndRedisplayDirEntry(*pDir, FSe, 0l, 0l, RDM_ContentsChanged);
- }
- }
- }
- }
-
-
- void ToggleHelp(void)
- {
- if (HelpActive)
- StopHelp();
- else
- StartHelp();
- }
-
-
- void StartHelp(void)
- {
- ASSERT_VALID(activeWindow);
-
- HelpControl(activeWindow, HC_GADGETHELP);
-
- //??? SelectGadget(&FSWinHelpGadget, FSwin, NULL, TRUE);
-
- HelpActive = TRUE;
- SetHelpPointer(activeWindow, TRUE);
-
- if (!CallHelp(0L, TRUE))
- {
- // Hilfe nicht verfügbar
- StopHelp();
-
- //??? SelectGadget(&FSWinHelpGadget, FSwin, NULL, FALSE);
- }
- }
-
-
- void StopHelp(void)
- {
- if (GadgetHelp)
- HelpControl(activeWindow, 0);
-
- SetHelpPointer(activeWindow, FALSE);
-
- CloseHelp();
-
- //??? SelectGadget(&FSWinHelpGadget, FSwin, NULL, FALSE);
-
- HelpActive = FALSE;
- }
-
-
- static BOOL isChildOf(const char *Parent, const char *Child)
- {
- size_t len;
-
- len = strlen(Parent);
- if (strnicmp(Parent, Child, len) != 0)
- return FALSE;
-
- if (Parent[len-1] == ':')
- return TRUE;
-
- if (Child[len] != '/')
- return FALSE;
-
- return TRUE;
- }
-
-
- static size_t InsertFSe(struct FSDir *Dir, struct FSDirEntry *FSe)
- {
- size_t InsertIndex, Index;
-
- // ggf. die Liste verlängern !
- if (Dir->fsd_DirCount >= Dir->fsd_ListSize)
- ExtendFSDir(Dir);
-
- InsertIndex = 0l;
- while (InsertIndex < Dir->fsd_DirCount &&
- (*BackupOpt->bo_FSCompare)(&Dir->fsd_EntryList[InsertIndex], &FSe) < 0)
- InsertIndex++;
-
- Dir->fsd_DirCount++;
-
- // einfügen ab <InsertIndex>
- for (Index=Dir->fsd_DirCount; Index > InsertIndex; Index--)
- Dir->fsd_EntryList[Index] = Dir->fsd_EntryList[Index-1];
-
- Dir->fsd_EntryList[InsertIndex] = FSe;
-
- return InsertIndex;
- }
-
-
- static BOOL isInWindow(struct Window *Win, short x, short y)
- {
- struct Layer *wLayer;
-
- wLayer = WhichLayer(&Win->WScreen->LayerInfo,
- x + Win->LeftEdge,
- y + Win->TopEdge);
-
- return (BOOL) (wLayer == Win->RPort->Layer);
- }
-
-
- static void GetPatternGadgetString(void)
- {
- stccpy(SelectPattern.RawName, GADSTRING(FSGadgets[GDX_FSPatternGadget]), sizeof(SelectPattern.RawName));
-
- if(ParsePatternNoCase(SelectPattern.RawName,
- SelectPattern.ParsedPattern,
- sizeof(SelectPattern.ParsedPattern) ) == -1)
- {
- alarm("%s: %s", __FUNC__, GetString(MSG_XLATEERROR_SELECT));
- SelectPattern.isParsed = FALSE;
- }
- else
- {
- SelectPattern.isParsed = TRUE;
- }
- }
-
-
- // Der FontName muß im Format "nnnnnnnnn.font/99" oder "nnnnnnnnn.font 99" vorliegen!
- BOOL FillTextAttrFromFontName(struct TextAttr *FontAttr, const char *FontName)
- {
- const char *fp;
- char *p;
- size_t Len;
-
- // zuerst die Länge des Namens bestimmen
- for (fp = FontName, Len = 0; *fp && '/' != *fp && ' ' != *fp; fp++, Len++);
-
- FontAttr->ta_Name = malloc(Len + 1);
- if (NULL == FontAttr->ta_Name)
- return FALSE;
-
- p = FontAttr->ta_Name;
- while (*FontName && '/' != *FontName && ' ' != *FontName)
- {
- *p++ = *FontName++;
- }
- *p = '\0'; // ta_Name mit '\0' abschließen
-
- // Trenner zwischen Name und Größe überspringen
- if (*FontName)
- FontName++;
-
- FontAttr->ta_YSize = atoi(FontName);
- FontAttr->ta_Style = FS_NORMAL;
- FontAttr->ta_Flags = 0;
-
- return TRUE;
- }
-
-
- void SetFSListFont(struct BackupOptions *Opt)
- {
- static struct TextAttr myTextAttr;
-
- FillTextAttrFromFontName(&myTextAttr, Opt->bo_ListFontName);
-
- FileDisplayScr.sFont = OpenDiskFont(&myTextAttr);
- if (NULL == FileDisplayScr.sFont)
- {
- alarm(GetString(MSG_CANNOTOPEN_LISTFONT),
- myTextAttr.ta_Name, myTextAttr.ta_YSize,
- DefaultFAttr.ta_Name, DefaultFAttr.ta_YSize
- );
- FileDisplayScr.sFont = OpenDiskFont(&DefaultFAttr);
- }
- if (myTextAttr.ta_Name)
- {
- free(myTextAttr.ta_Name);
- myTextAttr.ta_Name = NULL;
- }
- }
-
-
- void EndXGO(void)
- {
- if (FSwin && FSGadgets[GDX_FSGlobOptGadget])
- {
- GT_SetGadgetAttrs(FSGadgets[GDX_FSGlobOptGadget], FSwin, NULL,
- GA_Disabled, FALSE,
- TAG_END);
- }
- }
-
-
- static ULONG __interrupt __saveds DisplayFileSizeHookFunc(struct Hook *HookPtr,
- struct FSDirEntry *Record, struct ALVDrawMsg *Msg )
- {
- ULONG Result = 0l;
-
- if (ALV_GETUSERSTRING == Msg->alvdm_MethodID)
- {
- static char dBuff[40];
-
- switch (Record->fse_Typ)
- {
- case Volume:
- strcpy(dBuff, GetString(MSG_FILELIST_VOL));
- break;
- case Directory:
- strcpy(dBuff, GetString(MSG_FILELIST_DIR));
- break;
- case SoftLinkDir:
- case SoftLinkFile:
- strcpy(dBuff, GetString(MSG_FILELIST_SOFTLINK));
- break;
- case HardLinkFile:
- case HardLinkDir:
- strcpy(dBuff, GetString(MSG_FILELIST_HARDLINK));
- break;
- case Assign:
- strcpy(dBuff, GetString(MSG_FILELIST_ASSIGN));
- break;
- case File:
- myFormatString(dBuff, "%lU", Record->fse_Size);
- break;
- case Device:
- KMBytes(dBuff, Record->fse_Size);
- strcat(dBuff, GetString(MSG_FILELIST_PARTITION));
- break;
- }
-
- Result = (ULONG) dBuff;
- }
-
- return Result;
- }
-
-
- static ULONG __interrupt __saveds DisplayFileProtectionHookFunc(struct Hook *HookPtr,
- struct FSDirEntry *Record, struct ALVDrawMsg *Msg )
- {
- ULONG Result = 0l;
-
- if (ALV_GETUSERSTRING == Msg->alvdm_MethodID)
- {
- switch (Record->fse_Typ)
- {
- case Volume:
- case Device:
- case Assign:
- Result = (ULONG) "";
- break;
- case Directory:
- case File:
- case HardLinkFile:
- case HardLinkDir:
- case SoftLinkDir:
- case SoftLinkFile:
- Result = (ULONG) GetFileFlags(Record->fse_Protection);
- break;
- }
- }
-
- return Result;
- }
-
-
- static ULONG __interrupt __saveds DisplaySelectHookFunc(struct Hook *HookPtr,
- struct FSDirEntry *Record, struct ALVDrawMsg *Msg )
- {
- struct RastPort *rp;
- const short SelectMarkerWidth = 2 * 8;
-
- rp = Msg->alvdm_RastPort;
-
- switch (Msg->alvdm_MethodID)
- {
- case ALV_DRAW:
- if (!isFile(Record))
- {
- d(kprintf(__FUNC__ "/%ld: MinY=%ld MaxY=%ld\n", \
- __LINE__, Msg->alvdm_Bounds.MinY, Msg->alvdm_Bounds.MaxY));
-
- DrawSelectMarker(rp,
- Msg->alvdm_Bounds.MinX, Msg->alvdm_Bounds.MinY,
- SelectMarkerWidth, Record, Msg);
- }
- break;
-
- case ALV_GETBOUNDS:
- {
- Msg->alvdm_Bounds.MinX = 0;
- Msg->alvdm_Bounds.MinY = 0;
-
- if (isFile(Record))
- {
- Msg->alvdm_Bounds.MaxY = 0;
- Msg->alvdm_Bounds.MaxX = 0;
- }
- else
- {
- Msg->alvdm_Bounds.MaxY =
- Msg->alvdm_Bounds.MaxX = SelectMarkerWidth;
- }
- }
- break;
- }
-
- return 0l;
- }
-
-
- static ULONG __interrupt __saveds ClickFileHookFunc(struct Hook *HookPtr,
- struct FSDirEntry *Record, struct ALVDrawMsg *Msg )
- {
- ULONG Result = ALVRET_REUSE;
-
- if (ALV_RECORDCLICKED == Msg->alvdm_MethodID)
- {
- if (Msg->alvdm_ColNo == 1 && !isFile(Record) )
- {
- struct FSSelectedRecord *NewFSS;
-
- NewFSS = malloc(sizeof(struct FSSelectedRecord));
- if (NewFSS)
- {
- NewFSS->fsr_Record = Record;
- AddTail((struct List *) &SubDirRecordsList, (struct Node *) &NewFSS->fsr_Node);
- }
- Result = ALVRET_NOREUSE;
- }
- else
- Result = ALVRET_REUSE;
- }
-
- return Result;
- }
-
-
- static ULONG __interrupt __saveds SelectFileHookFunc(struct Hook *HookPtr,
- struct FSDirEntry *Record, struct ALVDrawMsg *Msg )
- {
- ULONG Result = 0l;
-
- if (ALV_RECORDSELECTED == Msg->alvdm_MethodID)
- {
- struct FSSelectedRecord *NewFSS;
-
- NewFSS = malloc(sizeof(struct FSSelectedRecord));
- if (NewFSS)
- {
- NewFSS->fsr_Record = Record;
- AddTail((struct List *) &SelectRecordsList, (struct Node *) &NewFSS->fsr_Node);
- }
- }
-
- return Result;
- }
-
-
- // Test, ob die Mauskoordinaten innerhalb des FSALVGadget liegen
- static BOOL isInFileView(WORD MouseX, WORD MouseY)
- {
- if (MouseX < FSGadgets[GDX_FSALVGadget]->LeftEdge ||
- MouseX >= FSGadgets[GDX_FSALVGadget]->LeftEdge + FSGadgets[GDX_FSALVGadget]->Width)
- return FALSE;
- if (MouseY < FSGadgets[GDX_FSALVGadget]->TopEdge ||
- MouseY >= FSGadgets[GDX_FSALVGadget]->TopEdge + FSGadgets[GDX_FSALVGadget]->Height)
- return FALSE;
-
- return TRUE;
- }
-
-
- void ShowWildcardOpt(const struct BackupOptions *Opts)
- {
- if (FSwin)
- {
- GT_SetGadgetAttrs(FSGadgets[GDX_FSWildTypeGadget], FSwin, NULL,
- GTTX_Text, Opts->bo_UseGrepPattern ? "#?" : "*",
- TAG_END);
- }
- }
-
-
- static void __interrupt DrawMarkerBox(struct RastPort *rp, short xMin, short xMax, short yMin, short yMax)
- {
- Point PointArray[8];
-
- PointArray[0].x = PointArray[3].x = xMax - 2;
- PointArray[1].x = PointArray[2].x = xMax;
- PointArray[4].x = PointArray[7].x = xMin + 2;
- PointArray[5].x = PointArray[6].x = xMin;
-
- PointArray[0].y = PointArray[7].y = yMin;
- PointArray[1].y = PointArray[6].y = yMin + 2;
- PointArray[2].y = PointArray[5].y = yMax - 2;
- PointArray[3].y = PointArray[4].y = yMax;
-
- Move(rp, PointArray[7].x, PointArray[7].y);
- PolyDraw(rp, 8, (WORD *) PointArray);
- }
-
-
- static void __interrupt DrawSelectMarker(struct RastPort *rp, short x, short y, short Width,
- const struct FSDirEntry *Record, const struct ALVDrawMsg *Msg)
- {
- short Height;
- short xMax, yMax;
- short wDiff = 3, hDiff = 3;
-
- Height = Msg->alvdm_Bounds.MaxY - y;
-
- xMax = x + Width - 1;
- yMax = y + Height - 1;
-
- if ((Height - 1 - 2 * hDiff) < 3)
- hDiff--;
-
- // DrawMarkerBox(rp, x, xMax, y, yMax);
-
- // leeres Rechteck zeichnen
- SetAPen(rp, Msg->alvdm_DrawInfo->dri_Pens[TEXTPEN]);
- Move(rp, x + wDiff, y + hDiff);
- Draw(rp, xMax - wDiff, y + hDiff);
- Draw(rp, xMax - wDiff, yMax - hDiff);
- Draw(rp, x + wDiff, yMax - hDiff);
- Draw(rp, x + wDiff, y + hDiff);
-
- // Record->dli_dNode->SelectState = GetDirSelectState(Record->dli_dNode);
-
- if (Record->fse_HasSelects)
- {
- // einige Files sind ausgewählt
- short k;
-
- for (k=x+wDiff; k<xMax-wDiff; k++)
- {
- Move(rp, k, yMax - hDiff);
- Draw(rp, xMax - wDiff, y + hDiff);
- }
- }
- else if (ST_Selected == Record->fse_Selected)
- {
- // alle Files sind ausgewählt
- RectFill(rp, x + wDiff, y + hDiff, xMax - wDiff, yMax - hDiff);
- }
- }
-
-
-