home *** CD-ROM | disk | FTP | other *** search
- #include "go.h"
- #include "display.h"
- #include "xfer.h"
-
- #include "sharedtransfer.proto.h"
- #include "filemanip.proto.h"
- #include "mouse.proto.h"
- #include "window.proto.h"
- #include "dircreate.proto.h"
- #include "delete.proto.h"
- #include "initdirs.proto.h"
- #include "inithotband.proto.h"
- #include "update.proto.h"
- #include "misc.proto.h"
- #include "launch.proto.h"
- #include "alerts.proto.h"
- #include <string.h>
- #include "windlist.h"
-
- /* todo: move to .h file */
- #define STDFILEWIDTH 304
-
- void
- newfolder (void)
- {
- Point pt;
- SFReply reply;
- long savecurdir;
- short savesfsavedisk;
- WindowPeek wp;
-
- wp = (WindowPeek) FrontWindow ();
- savecurdir = CurDirStore;
- savesfsavedisk = SFSaveDisk;
- if (browser_window_p ((WindowPtr) wp))
- {
- CurDirStore = (*(opendirinfo **) wp->refCon)->iodirid;
- SFSaveDisk = -(*(opendirinfo **) wp->refCon)->vrefnum;
- }
- #ifdef THINK_C
- SetPt (&pt, (screenBits.bounds.right - screenBits.bounds.left - STDFILEWIDTH) / 2,
- 100);
- SFPutFile (pt, (StringPtr) "\pNew Folder Name:", (StringPtr) "\pUntitled Folder",
- (ProcPtr) 0, &reply);
- #else
- SetPt (&pt, (qd.screenBits.bounds.right - qd.screenBits.bounds.left - STDFILEWIDTH) / 2,
- 100);
- SFPutFile (pt, (StringPtr) "\pNew Folder Name:", (StringPtr) "\pUntitled Folder",
- (DlgHookUPP) 0, &reply);
- #endif
- if (reply.good)
- {
- #ifdef THINK_C
- createdir (-SFSaveDisk, CurDirStore, reply.fName);
- #else
- createdir (-LMGetSFSaveDisk (), LMGetCurDirStore (), reply.fName);
- #endif
- #ifdef THINK_C
- changewindow (reply.fName, CurDirStore, -SFSaveDisk, updatemove);
- #else
- changewindow (reply.fName, LMGetCurDirStore (), -LMGetSFSaveDisk (), updatemove);
- #endif
- }
- CurDirStore = savecurdir;
- SFSaveDisk = savesfsavedisk;
- }
-
- void
- openitem (void)
- {
- if ((**g_selection)[0] != 0)
- activateicon ((**g_selection)[0], FALSE, TRUE);
- }
-
- void
- printitem (void)
- {
- launchcreator ((**g_selection)[0], appPrint);
- }
-
- int
- is_closable (WindowPtr wp)
- {
- return browser_window_p (wp);
- }
-
- void
- closeitem (void)
- {
- WindowPtr wp;
-
- wp = FrontWindow ();
- if (is_closable (wp))
- disposedirwindow (wp);
- }
-
- void
- saveitem (void)
- {
- /* todo */
- }
-
- void
- undolast (void)
- {
- /* todo */
- }
-
- void
- duplicatename (Str255 name)
- {
- /* todo: put in .h file */
- #define MAXNAMELEN 31
- #define SUFFIX " copy"
- short suffix_length;
-
- suffix_length = sizeof (SUFFIX) - 1;
- name[0] += suffix_length;
- if (name[0] > MAXNAMELEN)
- name[0] = MAXNAMELEN;
- memcpy(name + name[0] - suffix_length + 1, SUFFIX, suffix_length);
- }
-
- void
- duplicate (void)
- {
- item **ih;
- ControlHandle c;
- Str255 newname;
- unsigned char state;
- long flags;
-
- c = (**g_selection)[0];
- mystr255copy (newname, (*c)->contrlTitle);
- duplicatename (newname);
- ih = (item **) (*c)->contrlData;
- state = HGetState ((Handle) c);
- HLock ((Handle) c);
- if (!duplicate1file ((*ih)->vrefnum, (*ih)->vrefnum, (*ih)->ioparid,
- (*ih)->ioparid, (*c)->contrlTitle, newname, true, &flags))
- changewindow (newname, (*ih)->ioparid, (*ih)->vrefnum, updatemove);
- HSetState ((Handle) c, state);
- }
-
- /* todo: move to .h file */
- #define RENAMEDIALOGID 202
- #define NEWNAMEITEM 3
-
- void
- renameselection (void)
- {
- Rect r;
- item **ih;
- short itemnum, type;
- Handle itemh;
- DialogPtr dp;
- HParamBlockRec pb;
- ControlHandle c;
- OSErr e;
- Str255 s, s2;
- unsigned char state;
- short vrefnum;
- long parid;
- CInfoPBRec cpb;
-
- c = (**g_selection)[0];
-
- dp = GetNewDialog (RENAMEDIALOGID, (Ptr) 0, (WindowPtr) - 1);
-
- GetDItem (dp, NEWNAMEITEM, &type, &itemh, &r);
- SetIText (itemh, (*c)->contrlTitle);
- SelIText (dp, NEWNAMEITEM, 0, 32767);
-
- #ifdef THINK_C
- ModalDialog ((ProcPtr) 0, &itemnum);
- #else
- ModalDialog ((ModalFilterUPP) 0, &itemnum);
- #endif
- if (itemnum == OK)
- {
- GetDItem (dp, NEWNAMEITEM, &type, &itemh, &r);
- GetIText (itemh, s);
- ih = (item **) (*c)->contrlData;
- state = HGetState ((Handle) c);
- HLock ((Handle) c);
- pb.ioParam.ioNamePtr = (*c)->contrlTitle;
- pb.ioParam.ioMisc = (Ptr) s;
- pb.ioParam.ioVRefNum = (*ih)->vrefnum;
- pb.fileParam.ioDirID = (*ih)->ioparid;
- e = PBHRename (&pb, false);
- HSetState ((Handle) c, state);
- if (e == noErr)
- {
- if (is_volume (c))
- s[++s[0]] = ':';
- mystr255copy(s2, (*c)->contrlTitle);
- parid = (*ih)->ioparid;
- vrefnum = (*ih)->vrefnum;
- replaceselected (0);
- if ((*ih)->action == OPENDIR)
- {
- cpb.dirInfo.ioNamePtr = s;
- cpb.dirInfo.ioVRefNum = (*ih)->vrefnum;
- cpb.dirInfo.ioDrDirID = (*ih)->ioparid;
- cpb.dirInfo.ioFDirIndex = 0;
- e = PBGetCatInfo (&cpb, false);
- if (e == noErr)
- {
- update_title (c, s);
- }
- }
-
- if ((*c)->contrlOwner == g_hotband)
- SetCTitle (c, s);
- changewindow (s2, parid, vrefnum, removefromlist);
- changewindow (s, parid, vrefnum, updatemove);
-
- /* NOTE: after the first changewindow() call is made, c is no
- longer valid, so calls to SetCTitle (c, s); would really be
- a bad idea */
-
- }
- else if (e == dupFNErr)
- {
- ParamText ((StringPtr) "\pThat name is already in use.",
- (StringPtr) "\p", (StringPtr) "\p", (StringPtr) "\p");
- StopAlert (FOUR_PARAM_ALERT, (ProcPtr) 0);
- }
- else
- {
- doerror (e, (StringPtr) "\pPBHRename");
- }
- }
- DisposDialog (dp);
- }
-
- void
- deleteselection (void)
- {
- ControlHandle c;
- item **ih;
- short vrefnum;
- long parid;
- Str255 save_ctl_title;
-
- abortflag = 0;
-
- /* Don't worry about c being null because the menu choice would not have been
- * hilit
- */
- c = (**g_selection)[0];
- if ((*c)->contrlOwner == g_hotband)
- removeitemfromhotband (c);
- else
- {
- boolean_t was_folder_p;
-
- was_folder_p = is_folder (c);
- ih = (item **) (*c)->contrlData;
- vrefnum = (*ih)->vrefnum;
- parid = (*ih)->ioparid;
- changehot (c, 0, 0);
- replaceselected((ControlHandle) 0);
- mystr255copy (save_ctl_title, (*c)->contrlTitle);
- if (!delete1file (vrefnum, parid, save_ctl_title))
- changewindow (save_ctl_title, parid, vrefnum, removefromlist);
- if (was_folder_p)
- close_windows_no_longer_present ();
- }
- }
-