ecarroll@vax1.tcd.ie (Eddy Carroll) (05/07/90)
In article <9596@chaph.usc.edu>, aliu@aludra.usc.edu (Terminal Entry) writes: > In article <23114@uflorida.cis.ufl.EDU> scroll@beach.cis.ufl.edu () writes: >>Has any one noticed that the arp.library's file requester does not >>seem to allow long path names (such as DH0:lc/Compiler_Headers/intuition/ )? > > Ya, I have the same problem when trying to read some files using > Arp's requestor. Wonder if this is fixed in 2.0?? In fact, it seems to be fixed in ARP 1.3. Programs which use ArpAllocFreq() to allocate the file request structure passed to ARP's FileRequest() function automatically get directory names to 254 characters (as opposed to the older 33 character limit which is what you seem to be running into). Programs can also request this manually by setting the FR2F_LongPath bit in the fr_Flags2 field of the request structure. Programs released before ARP 1.3 only pass a 33 byte buffer to FileRequest() to store the directory name in so if it tried to store something longer there, it would probably trash someone else's memory. Followups directed to comp.sys.amiga.tech. -- Eddy Carroll ----* Genuine MUD Wizard | "You haven't lived until ecarroll@vax1.tcd.ie | you've died in MUD!" ecarroll%vax1.tcd.ie@cunyvm.cuny.edu | -- Richard Bartle
zupke@mars.jpl.nasa.gov (Brian Zupke) (09/13/90)
Howdy! Could anyone tell me how to use the ARP FileRequester function? Looking at the documentation (an not having an example) this is not very clear. BTW I have Manx Aztec 5.0. An example of its use would be perfect. Thanks in advance. -Brian
aaron@stat.tamu.edu (Aaron Hightower) (09/14/90)
In article <4811@jato.Jpl.Nasa.Gov> zupke@mars.UUCP (Brian Zupke) writes: >Howdy! Could anyone tell me how to use the ARP FileRequester function? >Looking at the documentation (an not having an example) this is not very >clear. BTW I have Manx Aztec 5.0. An example of its use would be >perfect. Thanks in advance. > >-Brian /* Example of the arp file-requester (Aaron Hightower) aaron@stat.tamu.edu (128.194.28.1) */ #include <stdio.h> #include <exec/types.h> #include <libraries/arpbase.h> struct ArpBase *ArpBase; struct FileRequester fileRequester; char filename[FCHARS+1]; char filepath[DSIZE+1]; main() { fileRequester.fr_Hail = "Does this work?"; fileRequester.fr_File = filename; fileRequester.fr_Dir = filepath; if((ArpBase = (struct ArpBase *) OpenLibrary("arp.library",0))==NULL) { printf("Unable to open the arp.library.\nPlease use the arp.library %s" ,"V1.3 or higher to run this program.\n"); exit(0); } FileRequest(&fileRequester); printf("File: %s, Dir: %s\n",fileRequester.fr_File,fileRequester.fr_Dir); CloseLibrary(ArpBase); return 0; }
koshy@abekrd.UUCP (Koshy Abraham) (09/17/90)
In <8240@helios.TAMU.EDU> aaron@stat.tamu.edu (Aaron Hightower) writes: >In article <4811@jato.Jpl.Nasa.Gov> zupke@mars.UUCP (Brian Zupke) writes: >>Howdy! Could anyone tell me how to use the ARP FileRequester function? >>Looking at the documentation (an not having an example) this is not very >>clear. BTW I have Manx Aztec 5.0. An example of its use would be >>perfect. Thanks in advance. >> >>-Brian >/* Example of the arp file-requester (Aaron Hightower) > aaron@stat.tamu.edu (128.194.28.1) */ [EXAMPLE DELETED] Here is some code taken from my EPROM programmer project (which will be posted to Tad very soon - sorry to all who have been waiting). This example shows how to call the requester the 1.3 way (I think), i.e. by allocating the file requ- ester structure - useful for future compatiability. There are a couple of custom gadgets in the requester and the code shows how to handle these as well. I've only tried this with Aztec C3.6 so you may need to do some extra work to get it to work with other compilers, and there are some references to external variables and routines which you will have to sort-out. I hope this is what you are looking for. Note : I've had this working on an A1000 under 1.3 & 1.4b? and on A3000 under WB2.0. --EXAMPLE STARTS HERE--- /*************************************************************************** * * FileIO.c - file load save for Eprom Programmer. * * This file is Copyright (C) June 1989, Koshy Abraham. * * // * // * \\ // * K\A/b ***************************************************************************/ #include "main.h" /* mainly #include's like intuition.h etc */ #include "events.h" #include <stdio.h> #include <libraries/dos.h> #define STRINFO_P struct StringInfo * extern struct Screen *MyScreen; extern struct Window *MyWindow; extern struct TextAttr TOPAZ80; extern UBYTE *DataStart; /* My data buffer */ extern ULONG DataSize; /* Size of buffer in bytes*/ static struct Window *FRWind = NULL; UBYTE Gadget3SIBuff[8] = "1fff"; static struct StringInfo Gadget3SInfo = { Gadget3SIBuff, NULL, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, NULL }; static SHORT BorderVectors1[] = { 0,0, 57,0, 57,9, 0,9, 0,0 }; static struct Border Border1 = { -1,-1, 2, 0, JAM1, 5, BorderVectors1,NULL }; static struct IntuiText IText1 = { 2, 0, JAM1, -28, 1, NULL, (UBYTE *)"End", NULL }; static struct Gadget Gadget3 = { NULL, 161, 150, 56, 8, GADGHCOMP, RELVERIFY, STRGADGET, (APTR)&Border1, NULL, &IText1, NULL, (APTR)&Gadget3SInfo, 2000, NULL }; UBYTE Gadget2SIBuff[8] = "000000"; static struct StringInfo Gadget2SInfo = { Gadget2SIBuff, NULL, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, NULL }; static SHORT BorderVectors2[] = { 0,0, 57,0, 57,9, 0,9, 0,0 }; static struct Border Border2 = { -1, -1, 2, 0, JAM1, 5, BorderVectors2, NULL }; static struct IntuiText IText21 = { 3, 0, JAM1, 0, -10, NULL, (UBYTE *)"Set Save Address Range", NULL }; static struct IntuiText IText2 = { 2, 0, JAM1, -44, 1, NULL, (UBYTE *)"Start", &IText21 }; static struct Gadget Gadget2 = { &Gadget3, 60, 150, 56, 8, GADGHCOMP, RELVERIFY, STRGADGET, (APTR)&Border2, NULL, &IText2, NULL, (APTR)&Gadget2SInfo, 2001, NULL }; /* ProcSaveGads() - Process Save Gadgets. * Following function used when saving data. Sets up Start Address and End * Address gadgets on file requester. */ ProcSaveGads(Mask,Object) ULONG Mask; CPTR *Object; { struct Gadget *Gad; switch(Mask) { case FRF_NewWindFunc: ((struct NewWindow *)Object)->LeftEdge = 0; ((struct NewWindow *)Object)->Height = 146+20; FRWind = NULL; break; case FRF_AddGadFunc: AddGadget(FRWind = (struct Window *)Object, &Gadget2, 0L); AddGadget(((struct Window *)Object), &Gadget3, 0L); ActivateGadget(&Gadget2, (struct Window *)Object, 0L); break; case FRF_GEventFunc: switch ((ULONG)Object) { case 2001: if (FRWind) ActivateGadget(&Gadget3, FRWind, 0L); break; case 2000: break; } return(TRUE); case FRF_DoMsgFunc: ReplyMsg(Object); break; } } int GetFileName(freq, HailText, FullName, Function, FuncFlags) struct FileRequester *freq; char *HailText, FullName[]; void (*Function)(); BYTE FuncFlags; { int RetVal; freq->fr_Hail = HailText; freq->fr_Window = MyWindow; freq->fr_Function = (VOID(*)())Function; freq->fr_FuncFlags |= FuncFlags; /* FRF_AddGadFunc+FRF_GEventFunc+FRF_NewWindFunc+FRF_DoMsgFunc; */ RetVal = (ULONG)FileRequest(freq); if (RetVal) { strcpy(FullName, freq->fr_Dir); TackOn(FullName, freq->fr_File); } return RetVal; } #define LoadDirName LFReq->fr_Dir #define LoadFileName LFReq->fr_File struct FileRequester *LFReq = NULL; int LoadFile(Type) int Type; { char FileName[FCHARS+DSIZE+1]; char s[80]; int error = FALSE; ULONG ReadSize = 0L; struct FileHandle *fh; struct FileLock *dlock, *olock; FILE *fp; /* Allocate file requester, but let CloseLibrary(ArpBase) free it */ if ((!LFReq) && (LFReq = ArpAllocFreq())) return TRUE; /* for now */ if (GetFileName(LFReq, "Load File", /* LoadDirName, LoadFileName, */ \ FileName, NULL, 0)) { if (dlock = (struct FileLock *)Lock(LoadDirName, SHARED_LOCK)) olock = (struct FileLock *)CurrentDir((struct FileLock *)dlock); if (Type == PLS_SREC) { if (fp = fopen(LoadFileName, "r")) { ReadSize = LoadSRecord(fp, DataStart, DataSize); fclose(fp); } else error = TRUE; } else if (fh = (struct FileHandle *)Open(LoadFileName, (LONG)MODE_OLDFILE)) { switch(Type) { case PLS_AMOBJ: /* AMIGA OBJECT FILE */ Seek(fh, 16L, (LONG)OFFSET_BEGINNING); case PLS_BIN: /* BINARY */ ReadSize = Read(fh, DataStart, DataSize); break; } Close(fh); } else error = TRUE; if (error) GetOkCancel((struct Screen *)MyScreen,(struct Window *)MyWindow,\ "Load File Error !"); else { sprintf(s, "%ld Bytes Read.", ReadSize); GetOkCancel((struct Screen *)MyScreen,(struct Window *)MyWindow, s); UpdateScreen(); } CurrentDir((struct FileLock *)olock); UnLock((struct FileLock *)dlock); } return TRUE; } /* GetOkCancel((struct Screen *)MyScreen,(struct Window *)MyWindow,\ "File not found") */ #define SaveDirName SFReq->fr_Dir #define SaveFileName SFReq->fr_File struct FileRequester *SFReq = NULL; int SaveFile() { char FileName[FCHARS+DSIZE+1]; int error, flag; ULONG SStart, SEnd; struct FileHandle *sfh; struct FileLock *dlock, *flock, *olock; /* Allocate file requester, but let CloseLibrary(ArpBase) free it */ if (!SFReq) SFReq = ArpAllocFreq(); error = 0; if (GetFileName(SFReq, "Save Block to File", FileName,\ (VOID (*) ())ProcSaveGads,\ (UBYTE)(FRF_AddGadFunc+FRF_GEventFunc+FRF_NewWindFunc+FRF_DoColor))) { error = 1; if (HexToBin(Gadget2SIBuff, &SStart)) { if (HexToBin(Gadget3SIBuff, &SEnd)) { if (SStart<=SEnd && SStart<DataSize && SEnd<DataSize) { error = 0; /* I discovered TackOn() too late to use it here insted of */ /* Lock()ing directories and files. Anyway this works. */ if (dlock = (struct FileLock *)Lock(SaveDirName, SHARED_LOCK)) { olock = (struct FileLock *)CurrentDir((struct FileLock *)\ dlock); flag = TRUE; if (flock = (struct FileLock *)Lock(SaveFileName,\ ACCESS_WRITE)) { flag = GetOkCancel((struct Screen *)MyScreen,\ (struct Window *)MyWindow, "Overwrite File ?"); UnLock((struct FileLock *)flock); } if (flag) { if ((sfh = (struct FileHandle *)Open(SaveFileName,\ MODE_NEWFILE))) { Write((struct FileHandle *)sfh, &DataStart[SStart],\ (LONG)(SEnd-SStart+1)); Close((struct FileHandle *)sfh); } } CurrentDir((struct FileLock *)olock); UnLock((struct FileLock *)dlock); } } } } } if (error) GetOkCancel((struct Screen *)MyScreen, (struct Window *)MyWindow,\ "ERROR: Address Set wrong."); return TRUE; } ---END OF EXAMPLE--- Regards. Koshy. -- Koshy Abraham UUCP: ...!uunet!mcsun!ukc!pyrltd!abekrd!koshy Abekas Video Systems Ltd. NET: koshy@abekrd.co.uk // 12 Portman Rd, Reading, PHONE: +44 734 585421 // Berkshire. RG3 1EA. FAX: +44 734 597267 \\ // United Kingdom. TELEX: 847579 K\A/b