home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
200-299
/
ff245.lzh
/
PathMaster
/
lattice
/
fsdata.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-09-06
|
15KB
|
440 lines
/* --------------------------------------------------------------------
* FSDATA.C - PathMaster(tm) Super File Selector structure data.
* Copyright © 1987-1989 by Justin V. McCormick. All Rights Reserved.
* -------------------------------------------------------------------- */
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/memory.h>
#include <exec/ports.h>
#include <exec/io.h>
#include <exec/semaphores.h>
#include <graphics/gfx.h>
#include <graphics/view.h>
#include <graphics/rastport.h>
#include <graphics/layers.h>
#include <graphics/text.h>
#include <intuition/intuition.h>
#include <libraries/dos.h>
#include "fs.h"
/* Buffers for string gadgets */
BYTE FileUndoBuffer[PATHSTRSIZE]; /* StringInfo undo buffer */
BYTE FileUndoName[FILESTRSIZE]; /* StringInfo undo for filename */
BYTE FSIgnorePat[FILESTRSIZE]; /* Pattern to avoid buffer */
BYTE fspathbuf1[PATHSTRSIZE];
BYTE fspathbuf2[PATHSTRSIZE];
BYTE FSPatternUndoBuffer[MATCHSTRSIZE]; /* FSPatternInfo undo */
BYTE FSWinTitleStr[80]; /* Global window title buffer */
BYTE FSwstr[PATHSTRSIZE*2]; /* General purpose work buffer */
/* Strings for IntuiText */
UBYTE DevLabelStr0[8] = "";
UBYTE DevLabelStr1[8] = "";
UBYTE DevLabelStr2[8] = "";
UBYTE DevLabelStr3[8] = "";
UBYTE FSPathLabelStr[] = "PATH";
UBYTE FSFileLabelStr[] = "FILE";
UBYTE EmptyStr[] = "";
UBYTE FSPatternLabelStr[] = "PATTERN";
UBYTE FSDevSortLabelStr[] = "DEVICE SORT";
UBYTE ParentLabelStr[] = "Parent";
UBYTE RootLabelStr[] = "Root";
UBYTE FSUndoLabelStr[] = "Last Dir";
UBYTE AlphaLabelStr[] = "Alpha";
UBYTE SizeLabelStr[] = "Size";
UBYTE TimeLabelStr[] = "Date";
/* Other strings used for formatting and comparisons */
UBYTE fsdayspermonth[12] =
{
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
BYTE fsdatefmtstr[] = "%02ld-%02ld-%02ld %02ld:%02ld:%02ld";
BYTE fsbaddatestr[] = "00-00-00 00:00:00";
BYTE fstempdate[40];
BYTE FSSizeFmtStr[] = "%8ld ";
BYTE FSDirFmtStr[] = " DIR ";
BYTE SlashStr[] = "/";
BYTE ColonStr[] = ":";
BYTE SplatStr[] = "*";
BYTE RamDirNameStr[] = "RAM:";
#ifdef BENCHMARK
BYTE timermsg1[] = "Elapsed";
#endif
/* Damn long chunk of error messages */
BYTE fserrmsg0[] = "File in use";
BYTE fserrmsg1[] = "File already exists";
BYTE fserrmsg2[] = "Directory not found!";
BYTE fserrmsg3[] = "Path not found!";
BYTE fserrmsg4[] = "Unknown DOS packet";
BYTE fserrmsg5[] = "Invalid stream name";
BYTE fserrmsg6[] = "Invalid file lock";
BYTE fserrmsg7[] = "File not of required type";
BYTE fserrmsg8[] = "Disk not validated";
BYTE fserrmsg9[] = "Disk write protected!";
BYTE fserrmsg10[] = "Rename across devices";
BYTE fserrmsg11[] = "Directory not empty";
BYTE fserrmsg12[] = "Too many subdirectories!";
BYTE fserrmsg13[] = "Volume not available!";
BYTE fserrmsg14[] = "Seek error!";
BYTE fserrmsg15[] = "Comment too long";
BYTE fserrmsg16[] = "Disk full!";
BYTE fserrmsg17[] = "File delete protected!";
BYTE fserrmsg18[] = "File write protected!";
BYTE fserrmsg19[] = "File read protected?";
BYTE fserrmsg20[] = "Not a DOS disk!";
BYTE fserrmsg21[] = "No disk in drive!";
BYTE fserrmsg22[] = "Empty Directory!";
BYTE fserrmsg23[] = "No Directory!";
BYTE fserrmsg24[] = "Nothing matched PATTERN";
BYTE fserrmsg25[] = "Unknown Error!";
BYTE fserrmsg26[] = "No RAM?!";
BYTE fserrmsg27[] = "Reading...";
BYTE fserrmsg28[] = "Sorting...";
BYTE fserrmsg29[] = "Select Filename:";
BYTE *fserrmsgs[] =
{
fserrmsg0,
fserrmsg1,
fserrmsg2,
fserrmsg3,
fserrmsg4,
fserrmsg5,
fserrmsg6,
fserrmsg7,
fserrmsg8,
fserrmsg9,
fserrmsg10,
fserrmsg11,
fserrmsg12,
fserrmsg13,
fserrmsg14,
fserrmsg15,
fserrmsg16,
fserrmsg17,
fserrmsg18,
fserrmsg19,
fserrmsg20,
fserrmsg21,
fserrmsg22,
fserrmsg23,
fserrmsg24,
fserrmsg25,
fserrmsg26,
fserrmsg27,
fserrmsg28,
fserrmsg29
};
#ifdef STANDALONE
struct TextFont *FSTextFont; /* TextFont pointer for Text */
struct TextAttr Def8Text =
{
(UBYTE *)"topaz.font", /* Font Name */
8, /* Font Height */
FS_NORMAL, /* Style */
FPF_ROMFONT /* Preferences */
};
BYTE TimerName[] = "timer.device";
#else
extern struct TextAttr Def8Text;
#endif
/* IntuiText for Path and File labels */
struct IntuiText FSDevSortTxt = { LABELFPEN, LABELBPEN, JAM2, 350, 0, &Def8Text, FSDevSortLabelStr, 0L };
struct IntuiText FSPatternTxt = { LABELFPEN, LABELBPEN, JAM2, 0, 24, &Def8Text, FSPatternLabelStr, &FSDevSortTxt };
struct IntuiText FSFileTxt = { LABELFPEN, LABELBPEN, JAM2, 0, 12, &Def8Text, FSFileLabelStr, &FSPatternTxt };
struct IntuiText FSPathTxt = { LABELFPEN, LABELBPEN, JAM2, 0, 0, &Def8Text, FSPathLabelStr, &FSFileTxt };
/* Gadgets ------------------------------------------------------------ */
/* The File Gadgets */
WORD FSGBox2[] =
{
4,11, 461,11, 461,22, 4,22, 4,33, 461,33, 461,44, 4,44, 4,55, 461,55,
461,66, 4,66, 4,77, 461,77, 461,88, 4,88, 4,99, 461,99, 461,110, 4,110,
4,121, 461,121, 461,11, 4,11, 4,121
};
struct Border FSFileGadBorder = { -5, -12, SBORDFPEN, SBORDBPEN, JAM1, 25, FSGBox2, 0L };
struct Gadget FSFileGad0 =
{
0L, 5, 12, 456, 109, GADGHNONE, GADGIMMEDIATE, BOOLGADGET,
(APTR)&FSFileGadBorder, 0L, 0L, 0L, 0L, 50, 0L
};
/* Arrow stuff */
WORD FSSlideBData[] = { 0,-1, 26,-1, 26,85, 0,85, 0,-1 };
WORD FSABox2[] = { 0,0, 13,0, 13,10, 0,10, 0,0 };
WORD FSABox1[] = { 0,0, 26,0, 26,10, 0,10, 0,0 };
WORD FSUpArrowData[] = { 14, 2, 14, 8, 13, 8, 13, 2, 12, 3, 15, 3, 16, 4, 11, 4, 10, 5, 17, 5 };
struct Border FSSlideBorder = { 0, -87, SBORDFPEN, 0, JAM1, 5, FSSlideBData, 0L };
struct Border FSUpArrow2 = { -7, 0, ARROWFPEN, 0, JAM1, 10, FSUpArrowData, 0L };
struct Border FSUpBorder2 = { 0, 0, ARROWBPEN, 0, JAM1, 5, FSABox2, &FSUpArrow2 };
struct Border FSUpArrow = { 0, 0, ARROWFPEN, 0, JAM1, 10, FSUpArrowData, &FSSlideBorder };
struct Border FSUpBorder = { 0, 0, ARROWBPEN, 0, JAM1, 5, FSABox1, &FSUpArrow };
WORD FSDownArrowData[] = { 14, 8, 14, 2, 13, 2, 13, 8, 12, 7, 15, 7, 16, 6, 11, 6, 10, 5, 17, 5 };
struct Border FSDownArrow2 = { -7, 0, ARROWFPEN, 0, JAM1, 10, FSDownArrowData, 0L };
struct Border FSDownBorder2 = { 0, 0, ARROWBPEN, 0, JAM1, 5, FSABox2, &FSDownArrow2 };
struct Border FSDownArrow = { 0, 0, ARROWFPEN, 0, JAM1, 10, FSDownArrowData, 0L };
struct Border FSDownBorder = { 0, 0, ARROWBPEN, 0, JAM1, 5, FSABox1, &FSDownArrow };
struct Gadget FSNextDevs =
{
&FSFileGad0,
308, 146, 14, 11, GADGHCOMP, GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
(APTR)&FSUpBorder2, 0L, 0L, 0L, 0L, 43, 0L
};
struct Gadget FSPrevDevs =
{
&FSNextDevs,
308, 158, 14, 11, GADGHCOMP, GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
(APTR)&FSDownBorder2, 0L, 0L, 0L, 0L, 42, 0L
};
struct Gadget FSDownGad =
{
&FSPrevDevs,
464, 111, 27, 11, GADGHCOMP, GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
(APTR)&FSDownBorder, 0L, 0L, 0L, 0L, 41, 0L
};
struct Gadget FSUpGad =
{
&FSDownGad,
464, 99, 27, 11, GADGHCOMP, GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
(APTR)&FSUpBorder, 0L, 0L, 0L, 0L, 40, 0L
};
/* Our Slide gadget */
struct Image FSSlideKnob;
struct PropInfo FSSlideProp = { AUTOKNOB|FREEVERT|PROPBORDERLESS, 0, 0, 0xffff, 0xffff, 0, 0, 0, 0, 0, 0 };
struct Gadget FSSlideGad =
{
&FSUpGad,
467, 13, 21, 83, GADGHNONE|GADGIMAGE, GADGIMMEDIATE|RELVERIFY, PROPGADGET,
(APTR)&FSSlideKnob, 0L, 0L, 0L, (APTR)&FSSlideProp, 33, 0L
};
/* The three string gadgets */
WORD FSGBox4[] = { 0, 0, 238, 0, 238, 11, 0, 11, 0, 0 };
struct Border FSStringBord2 = { -3, -2, SBORDFPEN, SBORDBPEN, JAM1, 5, FSGBox4, 0L };
WORD FSGBox3[] = { 0, 0, 262, 0, 262, 11, 0, 11, 0, 0 };
struct Border FSStringBord = { -3, -2, SBORDFPEN, SBORDBPEN, JAM1, 5, FSGBox3, 0L };
struct StringInfo FSPathInfo = { 0L, (UBYTE *)FileUndoBuffer, 0, PATHSTRSIZE-1, 0, 0, 0, 0, 0, 0, 0L, 0L, 0L };
struct Gadget FSPathGad =
{
&FSSlideGad, 42, 125, 260, 10, GADGHCOMP, GADGIMMEDIATE|RELVERIFY, STRGADGET,
(APTR)&FSStringBord, 0L, 0L, 0L, (APTR)&FSPathInfo, 32, 0L
};
struct StringInfo FSFileInfo = { 0L, (UBYTE *)FileUndoName, 0, FILESTRSIZE-1, 0, 0, 0, 0, 0, 0, 0L, 0L, 0L };
struct Gadget FSFileGad =
{
&FSPathGad, 42, 136, 260, 10, GADGHCOMP, GADGIMMEDIATE|RELVERIFY, STRGADGET,
(APTR)&FSStringBord, 0L, 0L, 0L, (APTR)&FSFileInfo, 31, 0L
};
struct StringInfo FSPatternInfo = { 0L, (UBYTE *)FSPatternUndoBuffer, 0, FILESTRSIZE-1, 0, 0, 0, 0, 0, 0, 0L, 0L, 0L };
struct Gadget FSPatternGad =
{
&FSFileGad, 66, 147, 236, 10, GADGHCOMP, GADGIMMEDIATE|RELVERIFY, STRGADGET,
(APTR)&FSStringBord2, 0L, 0L, 0L, (APTR)&FSPatternInfo, 30, 0L
};
/* The directory gadgets */
struct Image FSDirImg2 = { 1,1, 51,9, 0, 0L, 0, GADFILLPEN, 0L };
struct Image FSDirImg1 = { 0,0, 53,11, 0, 0L, 0, GADBORDPEN, &FSDirImg2 };
struct IntuiText ParentTxt = { GADTFPEN, GADTBPEN, JAM2, 3, 2, &Def8Text, ParentLabelStr, 0L };
struct Gadget ParentGad =
{
&FSPatternGad,
324, 134, 53, 11, GADGHCOMP|GADGIMAGE, RELVERIFY, BOOLGADGET,
(APTR)&FSDirImg1, 0L, &ParentTxt, 0L, 0L, 25, 0L
};
struct IntuiText RootTxt = { GADTFPEN, GADTBPEN, JAM2, 11, 2, &Def8Text, RootLabelStr, 0L };
struct Gadget RootGad =
{
&ParentGad,
379, 134, 53, 11, GADGHCOMP|GADGIMAGE, RELVERIFY, BOOLGADGET,
(APTR)&FSDirImg1, 0L, &RootTxt, 0L, 0L, 24, 0L
};
struct IntuiText RAMTxt = { GADTFPEN, GADTBPEN, JAM2, 11, 2, &Def8Text, DevLabelStr0, 0L };
struct Gadget RAMGad =
{
&RootGad,
324, 146, 53, 11, GADGHCOMP|GADGIMAGE, RELVERIFY, BOOLGADGET,
(APTR)&FSDirImg1, 0L, &RAMTxt, 0L, 0L, 23, 0L
};
struct IntuiText DF0Txt = { GADTFPEN, GADTBPEN, JAM2, 11, 2, &Def8Text, DevLabelStr1, 0L };
struct Gadget DF0Gad =
{
&RAMGad,
379, 146, 53, 11, GADGHCOMP|GADGIMAGE, RELVERIFY, BOOLGADGET,
(APTR)&FSDirImg1, 0L, &DF0Txt, 0L, 0L, 22, 0L
};
struct IntuiText NIL1Txt = { GADTFPEN, GADTBPEN, JAM2, 11, 2, &Def8Text, DevLabelStr2, 0L };
struct Gadget NIL1Gad =
{
&DF0Gad,
324, 158, 53, 11, GADGHCOMP|GADGIMAGE, RELVERIFY, BOOLGADGET,
(APTR)&FSDirImg1, 0L, &NIL1Txt, 0L, 0L, 21, 0L
};
struct IntuiText NIL2Txt = { GADTFPEN, GADTBPEN, JAM2, 11, 2, &Def8Text, DevLabelStr3, 0L };
struct Gadget NIL2Gad =
{
&NIL1Gad,
379, 158, 53, 11, GADGHCOMP|GADGIMAGE, RELVERIFY, BOOLGADGET,
(APTR)&FSDirImg1, 0L, &NIL2Txt, 0L, 0L, 20, 0L
};
/* Sort gadgets */
struct IntuiText TimeTxt = { GADTFPEN, GADTBPEN, JAM2, 11, 2, &Def8Text, TimeLabelStr, 0L };
struct Gadget TimeGad =
{
&NIL2Gad,
438, 158, 53, 11, GADGHCOMP|GADGIMAGE, TOGGLESELECT|GADGIMMEDIATE, BOOLGADGET,
(APTR)&FSDirImg1, 0L, &TimeTxt, 0L, 0L, 12, 0L
};
struct IntuiText SizeTxt = { GADTFPEN, GADTBPEN, JAM2, 11, 2, &Def8Text, SizeLabelStr, 0L };
struct Gadget SizeGad =
{
&TimeGad,
438, 146, 53, 11, GADGHCOMP|GADGIMAGE, TOGGLESELECT|GADGIMMEDIATE, BOOLGADGET,
(APTR)&FSDirImg1, 0L, &SizeTxt, 0L, 0L, 11, 0L
};
struct IntuiText AlphaTxt = { GADTFPEN, GADTBPEN, JAM2, 6, 2, &Def8Text, AlphaLabelStr, 0L };
struct Gadget AlphaGad =
{
&SizeGad,
438, 134, 53, 11, SELECTED|GADGHCOMP|GADGIMAGE, TOGGLESELECT|GADGIMMEDIATE, BOOLGADGET,
(APTR)&FSDirImg1, 0L, &AlphaTxt, 0L, 0L, 10, 0L
};
/* Cancel, select and undo gadgets */
struct Image FSOptImg2 = { 1,1, 72,9, 0, 0L, 0, GADFILLPEN, 0L };
struct Image FSOptImg1 = { 0,0, 74,11, 0, 0L, 0, GADBORDPEN, &FSOptImg2 };
struct IntuiText FSUndoTxt = { GADTFPEN, GADTBPEN, JAM2, 6, 2, &Def8Text, FSUndoLabelStr, 0L };
struct Gadget FSUndoGad =
{
&AlphaGad,
228, 158, 74, 11, GADGHCOMP|GADGIMAGE, RELVERIFY, BOOLGADGET,
(APTR)&FSOptImg1, 0L, &FSUndoTxt, 0L, 0L, 3, 0L
};
struct IntuiText FSCancelTxt = { GADTFPEN, GADTBPEN, JAM2, 10, 2, &Def8Text, EmptyStr, 0L };
struct Gadget FSCancelGad =
{
&FSUndoGad,
146, 158, 74, 11, GADGHCOMP|GADGIMAGE, RELVERIFY, BOOLGADGET,
(APTR)&FSOptImg1, 0L, &FSCancelTxt, 0L, 0L, 2, 0L
};
struct IntuiText FSSelectTxt = { GADTFPEN, GADTBPEN, JAM2, 13, 2, &Def8Text, EmptyStr, 0L };
struct Gadget FSSelectGad =
{
&FSCancelGad,
64, 158, 74, 11, GADGHCOMP|GADGIMAGE, RELVERIFY, BOOLGADGET,
(APTR)&FSOptImg1, 0L, &FSSelectTxt, 0L, 0L, 1, 0L
};
struct IntuiText FSUserTxt = { GADTFPEN, GADTBPEN, JAM2, 13, 2, &Def8Text, EmptyStr, 0L };
struct Gadget FSUserGad =
{
&FSSelectGad,
64, 158, 74, 11, GADGHCOMP|GADGIMAGE, RELVERIFY, BOOLGADGET,
(APTR)&FSOptImg1, 0L, &FSUserTxt, 0L, 0L, 0, 0L
};
/* Array of currently visible "gadget" text */
struct file_node *FSFileNodes[10];
/* Array of pointers to device name Gadgets */
struct Gadget *DevGads[4] =
{
&RAMGad,
&DF0Gad,
&NIL1Gad,
&NIL2Gad
};
/* Array of pointers to device name IntuiText strings */
struct IntuiText *DevTxts[4] =
{
&RAMTxt,
&DF0Txt,
&NIL1Txt,
&NIL2Txt
};
/* Array of pointers to currently visible device names */
UBYTE *CurDevNames[4];
/* AreaFill Pattern */
UWORD EmptyPattern[2] = { 0x8888, 0x2222 };
/* Window Stuff ------------------------------------------------------- */
struct NewWindow FSnw =
{
0, 11, 495, 171, 0, 1,
GADGETUP|GADGETDOWN|MOUSEBUTTONS|RAWKEY|DISKINSERTED|DISKREMOVED|INTUITICKS,
WINDOWDRAG|WINDOWDEPTH|SMART_REFRESH|NOCAREREFRESH|ACTIVATE|RMBTRAP,
0L, 0L, 0L, 0L, 0L, 0, 0, 0, 0, WBENCHSCREEN
};
struct DateStamp FSdirstamp; /* DateStamp of last dir locked */
/* Assorted uninitialized Variables */
struct List *devList; /* List of available devices */
struct dev_node *lastdev; /* Last visible disk name */
struct List *fnList; /* Head node of dir list */
struct file_node *topfin; /* Top visible node */
BPTR FSLock; /* FileLock pointer */
struct FileInfoBlock *FSFib; /* General purpose Fib pointer */
struct FSRequest *FSReq; /* Global pointer to currentreq */
struct InfoData *FSInfo; /* InfoData pointer */
struct MsgPort *FSTimerPort; /* Timer reply port */
struct RastPort *FSRPort; /* RastPort copy for Text */
struct timerequest *FSDelayReq; /* Timer IO request */
struct Window *FSWin = 0L;
ULONG fscurmicros;
ULONG fscursecs; /* New time value */
ULONG fsoldmicros;
ULONG fsoldsecs; /* Time storage for doubleclick */
ULONG FSSignalMask; /* Wait signal mask */
ULONG FSSignal; /* FS IDCMP signal bit */
ULONG FSUserSignal; /* UserIDCMP signal bit */
UWORD fsflags; /* Copy of FSReq->flags */
UWORD fsvheight; /* Slide Prop height */
UWORD fsvposition; /* Slide Prop position */
WORD FSCountDown; /* IntuiTick counter */
WORD fsdirlocked; /* Set if Lock()ed a dir */
WORD FSDone; /* Global exit flag */
WORD fsnumentries; /* Total count of entries */
WORD fsprevgadid; /* Last FileGad selected */
WORD fsstartedstr; /* Started a string entry flag */
WORD fstitlelength; /* Initial length of title */
WORD fsneedshow; /* 0=current, 1=needs refresh */
/* Initialized variables */
BYTE *OldFSPathBuf = fspathbuf2; /* Last path storage */
BYTE *FSPathBuf = fspathbuf1; /* Current path */
WORD fsvirgindir = 1; /* New directory flag */
WORD fstitstatus = 27; /* Current title message # */