oliphant@telepro.UUCP (Mike Oliphant) (11/14/90)
In article <27dc02lWe25G01@amdahl.uts.amdahl.com> kim@uts.amdahl.com (Kim DeVaughn) writes: >Sorry to drag this out across three followups, but I just noticed another VERY >annoying problem in the version that Phil put up on abcfd20 ... it does NOT >preserve the file's date and time stamp! This sparks a question. How do you modify the datestamp of a file? -- Mike Oliphant UUCP: alberta!herald!telepro!oliphant Internet: oliphant@telepro.uucp FidoNet: (1:140/91) - ZMH only * * Call TelePro, the development system for DIALOG Professional * * Phone: +1 306 249 2352 2400/9600/14400 bps HST * +1 306 652 2084 300/1200/2400 bps * FidoNet: (1:140/90) *
thad@cup.portal.com (Thad P Floryan) (11/17/90)
oliphant@telepro.UUCP (Mike Oliphant) in <oliphant.4412@telepro.UUCP> asks: This sparks a question. How do you modify the datestamp of a file? The operative phrase is "ACTION_SETDATE" as documented in an AmigaMAIL circa 1987. For a working example: File: 5007.comp-sys-amiga Path: ...!sri-unix!sri-spam!rutgers!mit-eddie!uw-beaver!ubc-vision!\ van-bc!jlydiatt From: jlydiatt@van-bc.UUCP (Jeff Lydiatt) Newsgroups: comp.sys.amiga Subject: Cp: A replacement for AmigaDos Copy Message-ID: <741@van-bc.UUCP> Date: 23 May 87 00:54:59 GMT Date-Received: 24 May 87 00:47:44 GMT Organization: Public Access Network, Vancouver, BC. Lines: 1217 Keywords: AmigaDos Copy Regular Expressions Here is a replacement for AmigaDog "copy" program that I have been working on for quite a while. It implements the AmigaDos pattern matching algorithm, the "all" command, and has the added bonus that it retains the date of copied file. It's my first posting to the net, and I have my fingers crossed that all goes well... Contents: cp.doc - documentation cp.c - the main program PatMatch.c - supporting routines to implement the pattern matching. setDate.c - gets and sets the file date. wb_parse.c - Aztec allows you to skip the workbench parms parse. makefile - to compile and link the whole thing. cp.uue - uuencoded cp The "setDate.c" file is enclosed below. BTW, Jeff's "cp" program permits the UNIX-like syntax: ``cp path/filename .'' (where "." means current directory) Thad Floryan [ thad@cup.portal.com (OR) ..!sun!portal!cup.portal.com!thad ] ==================== begin enclosed material ==================== ---- Cut Here and unpack ---- #!/bin/sh # This is a shell archive (shar 3.32) # made 11/17/1990 07:22 UTC by thad@thadlabs # Source directory /u/thad/tmp5 # # existing files WILL be overwritten # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 4628 -rw-r--r-- setDate.c # if touch 2>&1 | fgrep 'amc' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= setDate.c ============== echo "x - extracting setDate.c (Text)" sed 's/^X//' << 'SHAR_EOF' > setDate.c && X/* <setDate.c> X */ X X#include "exec/types.h" X#include "exec/ports.h" X#include "exec/io.h" X#include "exec/memory.h" X#include "libraries/dos.h" X#include "libraries/dosextens.h" X#include <stdio.h> X#define AZTEC 1 X#ifdef AZTEC X#include "functions.h" /* aztec C include */ X#endif X X#define ACTION_SETDATE_MODE 34L /* The packet type we will be playing with */ X#define DOSTRUE -1L /* AmigaDos TRUE */ X#define MAXARGS 7L /* limit in packet structure (dosextens.h) */ X#define NARGS 4L /* Number of args for setdate */ X X/*---------------------------------------------------------------------*/ X/* sendpkt: generalized send a dos packet. */ X/*---------------------------------------------------------------------*/ X Xstatic long sendpkt(pid,action,args,nargs) X Xstruct MsgPort *pid; /* process indentifier ... (handlers message port ) */ Xlong action, /* number of arguments in list */ X nargs; /* number of arguments in list */ XULONG args[]; /* a pointer to a argument list */ X{ X X struct MsgPort *replyport; X struct StandardPacket *packet; X X long count, res1; X ULONG *pargs; X X if(nargs > MAXARGS) return NULL; X X replyport = (struct MsgPort *) CreatePort(NULL,NULL); /* make reply port */ X if(!replyport) return NULL; X X packet = (struct StandardPacket *) X AllocMem((long)sizeof(struct StandardPacket),MEMF_PUBLIC | MEMF_CLEAR); X if(!packet) X { X FreeMem((void *)packet,(long)sizeof(struct StandardPacket)); X return(NULL); X } X X packet->sp_Msg.mn_Node.ln_Name = (char *) &(packet->sp_Pkt); /* link packet - */ X packet->sp_Pkt.dp_Link = &(packet->sp_Msg); /* to message */ X packet->sp_Pkt.dp_Port = replyport; /* set-up reply port */ X packet->sp_Pkt.dp_Type = action; /* what to do... */ X X /* move all the arguments to the packet */ X pargs = (ULONG *)&(packet->sp_Pkt.dp_Arg1); /* address of first argument */ X for(count=NULL;count < nargs && count < MAXARGS; ++count) X pargs[count]=args[count]; X X PutMsg(pid,packet); /* send packet */ X (void)WaitPort(replyport); /* wait for packet to come back */ X (void)GetMsg(replyport); /* pull message */ X X res1 = packet->sp_Pkt.dp_Res1; /* get result */ X X /* all done clean up */ X FreeMem((void *)packet,(long)sizeof(*packet)); X DeletePort(replyport); X X return(res1); X X} X X/*---------------------------------------------------------------------*/ X/* setDate: datestamp the given file with the given date. */ X/*---------------------------------------------------------------------*/ X XBOOL setDate( name, date ) Xchar *name; Xstruct DateStamp *date; X{ X struct MsgPort *task; /* for process id handler */ X ULONG arg[4]; /* array of arguments */ X char *bstr, strcpy(); /* of file to be set */ X long rc; X char *strchr(); X int strlen(); X X rc = 0; X X if ( !(bstr = (char *)AllocMem(68L, (long)(MEMF_PUBLIC)))) goto exit2; X if ( !(task = (struct MsgPort *)DeviceProc( name ))) goto exit1; X X /* Dos Packet needs the filename in Bstring format */ X X (void)strcpy( bstr+1, name ); X *bstr = strlen( name ); X X arg[0] = (ULONG)NULL; X arg[1] = (ULONG)IoErr(); /* lock on parent director set by DeviceProc() */ X arg[2] = (ULONG) bstr >> 2; X arg[3] = (ULONG) date; X rc = sendpkt( task, ACTION_SETDATE_MODE, arg, 4L ); X Xexit1: if ( bstr ) FreeMem( (void *)bstr, 68L ); Xexit2: if ( rc == DOSTRUE ) X return TRUE; X else X return FALSE; X} X X/*---------------------------------------------------------------------*/ X/* getDate: get the datestamp the given file. */ X/*---------------------------------------------------------------------*/ X XBOOL getDate(name, date ) Xchar *name; Xregister struct DateStamp *date; X{ X X struct FileInfoBlock *Fib; X ULONG FLock; X int result; X register struct DateStamp *d; X X if ( (FLock = (ULONG) Lock(name, (long)(ACCESS_READ) )) == NULL) X return FALSE; X X Fib = (struct FileInfoBlock * ) X AllocMem( (long)sizeof(struct FileInfoBlock), (long)(MEMF_CHIP)); X X if (Fib == NULL ) X result = FALSE; X else X { X if ( !Examine( FLock, Fib )) X result = FALSE; X else if ( Fib->fib_DirEntryType > 0 ) X result = FALSE; /* It's a directory */ X else X { X d = &Fib->fib_Date; X date->ds_Days = d->ds_Days; X date->ds_Minute = d->ds_Minute; X date->ds_Tick = d->ds_Tick; X result = TRUE; X } X FreeMem( (void *)Fib, (long)sizeof(struct FileInfoBlock) ); X } X X UnLock( FLock ); X return result; X} SHAR_EOF $TOUCH -am 1116232190 setDate.c && chmod 0644 setDate.c || echo "restore of setDate.c failed" set `wc -c setDate.c`;Wc_c=$1 if test "$Wc_c" != "4628"; then echo original size 4628, current size $Wc_c fi exit 0 ==================== end enclosed material ====================
ked01@ccc.amdahl.com (Kim DeVaughn) (11/18/90)
In article <36020@cup.portal.com> thad@cup.portal.com (Thad P Floryan) writes: > oliphant@telepro.UUCP (Mike Oliphant) in <oliphant.4412@telepro.UUCP> asks: > > This sparks a question. How do you modify the datestamp of a file? > > The operative phrase is "ACTION_SETDATE" as documented in an AmigaMAIL circa > 1987. > > The "setDate.c" file is enclosed below. BTW, Jeff's "cp" program permits the > > X#define ACTION_SETDATE_MODE 34L /* The packet type we will be playing with */ Though I wouldn't expect it to change, one should really use ACTION_SET_DATE, as defined in "libraries/dosextens.h". I hear tell that there is a regular ol' fn() call to do this under 2.0, BTW. /kim -- UUCP: kim@uts.amdahl.com -OR- ked01@juts.ccc.amdahl.com or: {sun,decwrl,hplabs,pyramid,uunet,oliveb,ames}!amdahl!kim DDD: 408-746-8462 USPS: Amdahl Corp. M/S 249, 1250 E. Arques Av, Sunnyvale, CA 94086 BIX: kdevaughn GEnie: K.DEVAUGHN CIS: 76535,25
thad@cup.portal.com (Thad P Floryan) (11/18/90)
ked01@ccc.amdahl.com (Kim DeVaughn) in <86XJ025203c601@JUTS.ccc.amdahl.com>
writes:
Though I wouldn't expect it to change, one should really use
ACTION_SET_DATE, as defined in "libraries/dosextens.h".
True. But ``ACTION_SET_DATE'' simply did NOT exist in the CBM-supplied header
file back then. It's easy to forget that when a system was evolving rapidly
as the Amiga, we had to alter the headers ourselves or "#define" the stuff
explicitly to avail oneself of "new" CBM-supplied information (as Jeff did with
his "cp" program).
Such a "problem" is common in the computer industry, and I'm not being critical
,
although I will say I was quite disappointed with DEC when they changed a lot
of the headers during the transition from VMS 4.7 to 5.0 which caused numerous
files to cease being compilable (luckily I anticipated that and retained copies
of the original headers :-)
Thad Floryan [ thad@cup.portal.com (OR) ..!sun!portal!cup.portal.com!thad ]