unsigned LocalDateTime( sys_handle fh, int *time, int *date, int set ) /**************************************************************/ { struct _FILESTATUS fstatus; struct _FDATE *pdate; struct _FTIME *ptime; unsigned rc; pdate = (struct _FDATE *)date; ptime = (struct _FTIME *)time; if( set ) { rc = DosQFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) ); if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) ); fstatus.ftimeLastWrite = *ptime; fstatus.fdateLastWrite = *pdate; rc = DosSetFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) ); if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) ); } else { rc = DosQFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) ); if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) ); *ptime = fstatus.ftimeLastWrite; *pdate = fstatus.fdateLastWrite; } return( 0 ); }
error_handle LocalDateTime( sys_handle fh, int *time, int *date, int set ) /************************************************************************/ { #if 0 struct _FILESTATUS fstatus; struct _FDATE *pdate; struct _FTIME *ptime; unsigned rc; pdate = (struct _FDATE *)date; ptime = (struct _FTIME *)time; if( set ) { rc = DosQueryFileInfo( fh, FIL_STANDARD, (PBYTE)&fstatus, sizeof( fstatus ) ); if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) ); fstatus.ftimeLastWrite = *ptime; fstatus.fdateLastWrite = *pdate; rc = DosSetFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) ); if( rc != 0 ) { return( StashErrCode( rc, OP_LOCAL ) ); } } else { rc = DosQueryFileInfo( fh, FIL_STANDARD, (PBYTE)&fstatus, sizeof( fstatus ) ); if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) ); *ptime = fstatus.ftimeLastWrite; *pdate = fstatus.fdateLastWrite; } return( 0 ); #else fh=fh;time=time;date=date;set=set; return 0; #endif }
/*@ XFile::SetFileInfo(XFileInfo * info) @group misc @remarks Set file-information. To access information the file must be open with XFILE_READONLY and XFILE_SHARE_DENYWRITE must be set! @parameters XFileInfo * pointer to an instance of XFileInfo @returns LONG result of the operatingsystem */ LONG XFile::SetFileInfo( const XFileInfo * info) { FILESTATUS3 buffer; char * p = (char*) &info->buffer; p += 4; memcpy( &buffer, p, sizeof(buffer)); return DosSetFileInfo(handle, FIL_STANDARD, &buffer, sizeof(buffer)); }
unsigned long SysPutEA(unsigned char *name, unsigned long numargs, RXSTRING args[], char *queuename, RXSTRING *retstr) { unsigned long rc; /* Ret code */ unsigned long act; /* open action */ void *fealist; /* fealist buffer */ EAOP2 eaop; /* eaop structure */ PFEA2 pfea; /* pfea structure */ HFILE handle; /* file handle */ if (numargs != 3 || !RXVALIDSTRING(args[0]) || !RXVALIDSTRING(args[1])) return INVALID_ROUTINE; if (rc = DosOpen2(args[0].strptr, &handle, &act, 0L, 0, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_ACCESS_READWRITE + OPEN_SHARE_DENYWRITE + OPEN_FLAGS_FAIL_ON_ERROR + OPEN_FLAGS_WRITE_THROUGH, NULL)) { RETVAL(rc) } if (DosAllocMem((PPVOID)&fealist, 0x00010000L, AllocFlag)) { BUILDRXSTRING(retstr, ERROR_NOMEM); return VALID_ROUTINE; } eaop.fpFEA2List = (PFEA2LIST)fealist;/* Set memory for the FEA */ eaop.fpGEA2List = NULL; /* GEA is unused */ pfea = &eaop.fpFEA2List->list[0]; /* point to first FEA */ pfea->fEA = '\0'; /* set the flags */ /* Size of FEA name field */ pfea->cbName = (BYTE)args[1].strlength; /* Size of Value for this one */ pfea->cbValue = (SHORT)args[2].strlength; /* Set the name of this FEA */ strcpy((PSZ)pfea->szName, args[1].strptr); /* Set the EA value */ memcpy((PSZ)pfea->szName+(pfea->cbName+1), args[2].strptr, args[2].strlength); pfea->oNextEntryOffset = 0; /* no next entry */ eaop.fpFEA2List->cbList = /* Set the total size var */ sizeof(ULONG) + sizeof(FEA2) + pfea->cbName + pfea->cbValue; /* set the file info */ rc = DosSetFileInfo(handle, 2, (PSZ)&eaop, sizeof(EAOP2)); DosClose(handle); /* Close the File */ DosFreeMem(fealist); /* Free the memory */ RETVAL(rc) }
int _ea_write (char *path, int handle, PFEA2LIST src) { ULONG rc; EAOP2 eaop; eaop.fpGEA2List = NULL; eaop.fpFEA2List = src; eaop.oError = 0; if (path != NULL) rc = DosSetPathInfo (path, 2, &eaop, sizeof (eaop), 0); else rc = DosSetFileInfo (handle, 2, &eaop, sizeof (eaop)); if (rc != 0) { _ea_set_errno (rc); return -1; } return 0; }
void copydate(const char *srcfile, const char *dstfile) { HFILE hfileSrc; APIRET rc; ULONG dontCare; //open sourcefile rc = DosOpen((PSZ)srcfile, &hfileSrc, &dontCare, 0, //filesize 0, //attributes OPEN_ACTION_FAIL_IF_NEW|OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_NO_LOCALITY|OPEN_SHARE_DENYNONE|OPEN_ACCESS_READONLY, (PEAOP2)NULL ); if(rc!=0) { fprintf(stderr,"%s: could not open %s (rc=%ld)\n",PROGNAME,srcfile,rc); exit(5); } //get date of sourcefile FILESTATUS3 fs3src; rc = DosQueryFileInfo(hfileSrc, FIL_STANDARD, (PVOID)&fs3src, sizeof(fs3src) ); if(rc!=0) { fprintf(stderr,"%s: could not get date of %s (rc=%ld)\n",PROGNAME,srcfile,rc); exit(5); } //close sourcefile rc = DosClose(hfileSrc); if(rc!=0) { fprintf(stderr,"%s: could not close %s\n",PROGNAME,srcfile); exit(5); } //open dstfile HFILE hfileDst; rc = DosOpen((PSZ)dstfile, &hfileDst, &dontCare, 0, //filesize 0, //attribute OPEN_ACTION_FAIL_IF_NEW|OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_NO_LOCALITY|OPEN_SHARE_DENYREADWRITE|OPEN_ACCESS_READWRITE, (PEAOP2)NULL ); if(rc!=0) { fprintf(stderr,"%s: could not open %s (rc=%ld)\n",PROGNAME,dstfile,rc); exit(5); } //get old info of dstfile FILESTATUS3 fs3dst; rc = DosQueryFileInfo(hfileDst, FIL_STANDARD, (PVOID)&fs3dst, sizeof(fs3dst) ); if(rc!=0) { fprintf(stderr,"%s: could not get date of %s (rc=%ld)\n",PROGNAME,dstfile,rc); exit(5); } //make new fs fs3dst.fdateCreation = fs3src.fdateCreation; fs3dst.ftimeCreation = fs3src.ftimeCreation; fs3dst.fdateLastWrite = fs3src.fdateLastWrite; fs3dst.ftimeLastWrite = fs3src.ftimeLastWrite; //set the date of dstfile rc = DosSetFileInfo(hfileDst, FIL_STANDARD, (PVOID)&fs3dst, sizeof(fs3dst) ); if(rc!=0) { fprintf(stderr,"%s: could not set date of %s (rc=%ld)\n",PROGNAME,dstfile,rc); exit(5); } //close dstfile rc = DosClose(hfileDst); if(rc!=0) { fprintf(stderr,"%s: could not close %s\n",PROGNAME,dstfile); exit(5); } //phew! }
uint32_t os2_get_file( CAMHandle hCam, CAMObjectInfoPtr pObjInfo, uint32_t handle, char* filename, int replace, int thumb) { APIRET rc = 0; uint32_t rtn = 0; HFILE hFile = 0; char * pBuf = 0; char * pMem = 0; char * pMsg = 0; ULONG ulSize; ULONG ul; FILESTATUS3 fs3; struct tm * ptm; do { if (!filename) { filename = pObjInfo->Filename; printf (" Saving %3d (%s)... ", handle, filename); } else printf (" Saving %3d (%s) as \"%s\"... ", handle, pObjInfo->Filename, filename); ulSize = (thumb ? pObjInfo->ThumbCompressedSize : pObjInfo->ObjectCompressedSize); if (ulSize == 0) { pMsg = "skipped - file size is zero\n"; break; } rc = DosOpen( filename, &hFile, &ul, ulSize, FILE_NORMAL, OPEN_ACTION_CREATE_IF_NEW | (replace ? OPEN_ACTION_REPLACE_IF_EXISTS : OPEN_ACTION_FAIL_IF_EXISTS), (OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE), 0); if (rc) { if (rc == ERROR_OPEN_FAILED) pMsg = "skipped - file exists\n"; break; } rc = DosAllocMem( (PVOID)&pMem, ulSize + 0x1000 - CAMCNR_DATASIZE, PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE); if (rc) break; // this trick eliminates 400 memcpy()s in UsbBulkRead() for a 2mb file; // after GetData() reads the first 500 bytes, the buffer it passes // to UsbBulkRead() will be page-aligned & can be used as-is pBuf = pMem + 0x1000 - CAMCNR_DATASIZE; if (thumb) rtn = GetThumb( hCam, handle, &pBuf); else rtn = GetObject( hCam, handle, &pBuf); if (rtn) { rc = (APIRET)rtn; break; } rc = DosWrite( hFile, pBuf, ulSize, &ul); if (rc) break; if (pObjInfo->CaptureDate == 0) { pMsg = "done\n"; break; } pMsg = "done - unable to set timestamp\n"; rc = DosQueryFileInfo( hFile, FIL_STANDARD, &fs3, sizeof(FILESTATUS3)); if (rc) break; ptm = localtime( &pObjInfo->CaptureDate); if (!ptm) break; fs3.fdateCreation.year = ptm->tm_year - 80; fs3.fdateCreation.month = ptm->tm_mon + 1; fs3.fdateCreation.day = ptm->tm_mday; fs3.ftimeCreation.hours = ptm->tm_hour; fs3.ftimeCreation.minutes = ptm->tm_min; fs3.ftimeCreation.twosecs = ptm->tm_sec / 2; fs3.fdateLastWrite = fs3.fdateCreation; fs3.ftimeLastWrite = fs3.ftimeCreation; rc = DosSetFileInfo( hFile, FIL_STANDARD, &fs3, sizeof(FILESTATUS3)); if (rc) break; pMsg = "done\n"; } while (0); if (pMem) DosFreeMem( pMem); if (hFile) DosClose( hFile); if (pMsg) printf( pMsg); else printf( "error - rc= %d\n", (int)rc); return rtn; }
long LocalGetFreeSpace( int drv ) /*******************************/ { struct _FSALLOCATE usage; #ifdef _M_I86 if( DosQFSInfo( drv, 1, (PBYTE)&usage, sizeof( usage ) ) ) { #else if( DosQueryFSInfo( drv, 1, (PBYTE)&usage, sizeof( usage ) ) ) { #endif return( -1L ); } return( usage.cbSector * usage.cSectorUnit * usage.cUnitAvail ); } error_handle LocalDateTime( sys_handle fh, int *time, int *date, int set ) /************************************************************************/ { struct _FILESTATUS fstatus; struct _FDATE *pdate; struct _FTIME *ptime; unsigned rc; pdate = (struct _FDATE *)date; ptime = (struct _FTIME *)time; if( set ) { #ifdef _M_I86 rc = DosQFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) ); #else rc = DosQueryFileInfo( fh, FIL_STANDARD, (PBYTE)&fstatus, sizeof( fstatus ) ); #endif if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) ); fstatus.ftimeLastWrite = *ptime; fstatus.fdateLastWrite = *pdate; rc = DosSetFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) ); if( rc != 0 ) { return( StashErrCode( rc, OP_LOCAL ) ); } } else { #ifdef _M_I86 rc = DosQFileInfo( fh, 1, (PBYTE)&fstatus, sizeof( fstatus ) ); #else rc = DosQueryFileInfo( fh, FIL_STANDARD, (PBYTE)&fstatus, sizeof( fstatus ) ); #endif if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) ); *ptime = fstatus.ftimeLastWrite; *pdate = fstatus.fdateLastWrite; } return( 0 ); } error_handle LocalGetCwd( int drive, char *where ) /************************************************/ { APIRET len; len = 256; #ifdef _M_I86 return( StashErrCode( DosQCurDir( drive, (PBYTE)where, &len ), OP_LOCAL ) ); #else return( StashErrCode( DosQueryCurrentDir( drive, (PBYTE)where, &len ), OP_LOCAL ) ); #endif }
//----------------------------- CMD_DosSetFileInfo ----------------------------- void CMD_DosSetFileInfo(HFILE hFile,LXIOCPA_DMN_CMDPARMPACKET* pParam ,PLXDOSSETFILEINFOSTRUCT pfi) { pParam->rc=DosSetFileInfo(pfi->hFile,pfi->ulInfoLevel ,&(pfi->filestatus),pfi->cbInfoBuf); }