コード例 #1
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
}
コード例 #2
0
ファイル: xio_file.cpp プロジェクト: OS2World/MM-SOUND-PM123
int XIOfile::getstat(XSTATL* st)
{
  FILE_REQUEST_DISK(this);
  ASSERT(s_handle != (HFILE)-1);
  APIRET rc = doQueryFileInfo(st);

  EAOP2  eaop2 = {NULL};
  if (rc == NO_ERROR)
  { eaop2.fpGEA2List = (GEA2LIST*)alloca(sizeof(GEA2LIST) + 5);
    eaop2.fpGEA2List->cbList = sizeof(GEA2LIST) + 5;
    eaop2.fpGEA2List->list[0].oNextEntryOffset = 0;
    eaop2.fpGEA2List->list[0].cbName = 5;
    memcpy(eaop2.fpGEA2List->list[0].szName, ".type", 6);
    // Since there is nor reasonable efficient way to determine the size of one EA
    // a rather large buffer is allocated.
    eaop2.fpFEA2List = (FEA2LIST*)alloca(sizeof(FEA2LIST) + sizeof(FEA2) + 256);
    eaop2.fpFEA2List->cbList = sizeof(FEA2LIST) + sizeof(FEA2) + 256;

    if (DosQueryFileInfo(s_handle, FIL_QUERYEASFROMLIST, &eaop2, sizeof eaop2) != NO_ERROR)
      eaop2.fpFEA2List = NULL; // No .TYPE EA.
  }
  FILE_RELEASE_DISK(this);

  if (rc != NO_ERROR)
  { errno = map_os2_errors(rc);
    return -1L;
  }

  *st->type = 0;
  if (eaop2.fpFEA2List)
    // Decode .TYPE EA
    eadecode(st->type, sizeof(st->type), eaop2.fpFEA2List->list);

  return 0;
}
コード例 #3
0
ファイル: os2io.c プロジェクト: Akin-Net/mozilla-central
PRInt32
_PR_MD_GETOPENFILEINFO64(const PRFileDesc *fd, PRFileInfo64 *info)
{
    PRFileInfo info32;
    PRInt32 rv = _PR_MD_GETOPENFILEINFO(fd, &info32);
    if (0 == rv)
    {
       info->type = info32.type;
       LL_UI2L(info->size,info32.size);
    
       info->modifyTime = info32.modifyTime;
       info->creationTime = info32.creationTime;
    }
    
    if (isWSEB)
    {
        APIRET rc ;
        FILESTATUS3L fstatus;

        rc = DosQueryFileInfo(fd->secret->md.osfd, FIL_STANDARDL, &fstatus, sizeof(fstatus));

        if (NO_ERROR != rc)
        {
            _PR_MD_MAP_OPEN_ERROR(rc);
            return -1;
        }

        if (! (fstatus.attrFile & FILE_DIRECTORY))
        {
            info->size = fstatus.cbFile;
        }
    }

    return rv;
}
コード例 #4
0
ファイル: os2.c プロジェクト: UIKit0/paragui
PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
{
    FILESTATUS3 fs;
    HFILE hfile = (HFILE) opaque;
    APIRET rc = DosQueryFileInfo(hfile, FIL_STANDARD, &fs, sizeof (fs));
    BAIL_IF_MACRO(os2err(rc) != NO_ERROR, NULL, -1);
    return((PHYSFS_sint64) fs.cbFile);
} /* __PHYSFS_platformFileLength */
コード例 #5
0
ファイル: utils.c プロジェクト: OS2World/UTIL-FILE-FSJ
/* --------------------------------------------------------------------------
 Return the size of a file from its handle.
- Parameters -------------------------------------------------------------
 HFILE hf      : file handle.
 PVOID pBuffer : read buffer.
 ULONG cb      : count of bytes to be read.
- Return value -----------------------------------------------------------
 LONGLONG : file size or -1 in case of error.
 ------------------------------------------------------------------------- */
LONGLONG fmSize(HFILE hf) {
   FILESTATUS3L fs;

   g.rc = DosQueryFileInfo(hf, FIL_STANDARDL, &fs, sizeof(fs));
   if (g.rc == NO_ERROR) return fs.cbFile;

   handleFileIOError(0, SZERR_FILESIZE, "", g.rc);
   return -1LL;
}
コード例 #6
0
ファイル: xio_file.cpp プロジェクト: OS2World/MM-SOUND-PM123
APIRET XIOfile64::doQueryFileInfo(XSTATL* st)
{ FILESTATUS3L fi;
  APIRET rc = DosQueryFileInfo(s_handle, FIL_STANDARDL, &fi, sizeof fi);
  if (rc != NO_ERROR)
    return rc;
  st->size = *(int64_t*)&fi.cbFile;
  st->atime = convert_OS2_ftime(fi.fdateLastAccess, fi.ftimeLastAccess);
  st->mtime = convert_OS2_ftime(fi.fdateLastWrite, fi.ftimeLastWrite);
  st->ctime = convert_OS2_ftime(fi.fdateCreation, fi.ftimeCreation);
  st->attr = fi.attrFile;
  return 0;
}
コード例 #7
0
ファイル: cfg_sys.c プロジェクト: OS2World/APP-COMM-ComScope
int ReadConfigFile(HWND hwnd, char szFileSpec[],char **ppBuffer)
  {
  ULONG ulStatus;
  HFILE hFile;
  FILESTATUS3 stFileInfo;
  int iCount;
  char szMessage[CCHMAXPATH];
  APIRET rc;

  if ((rc = DosOpen(szFileSpec,&hFile,&ulStatus,0L,0,1,0x0022,(PEAOP2)0L)) != 0)
    {
    if (hwnd != NULLHANDLE)
      {
      sprintf(szMessage,"Could not open %s - Error = %u",szFileSpec,rc);
      MessageBox(HWND_DESKTOP,szMessage);
      }
    return(0);
    }
  DosQueryFileInfo(hFile,1,&stFileInfo,sizeof(FILESTATUS3));
  iCount = stFileInfo.cbFile;
  if ((rc = DosAllocMem((PVOID)ppBuffer,(iCount + 10),(PAG_COMMIT | PAG_READ | PAG_WRITE))) != NO_ERROR)
    {
    if (hwnd != NULLHANDLE)
      {
      sprintf(szMessage,"Unable to Allocate memory to read %s - %u",szFileSpec,rc);
      MessageBox(HWND_DESKTOP,szMessage);
      }
    iCount = 0;
    }
  if (DosRead(hFile,(PVOID)*ppBuffer,iCount,(ULONG *)&iCount) != 0)
    {
    DosFreeMem(*ppBuffer);
    iCount = 0;
    }
  else
    {
    /*
    ** ignore/remove EOF character, if present
    */
    if ((*ppBuffer)[(iCount) - 1] == '\x1a')
      iCount--;
    /*
    **  Add LF and CR to end of file, if not already there
    */
    if ((*ppBuffer)[iCount - 1] != '\x0a')
      {
      (*ppBuffer)[(iCount)++] = '\x0d';
      (*ppBuffer)[(iCount)++] = '\x0a';
      }
    }
  DosClose(hFile);
  return(iCount);
  }
コード例 #8
0
/*@ XFile::GetFileInfo(XFileInfo * info)
@group misc
@remarks Query information about files. To access information the
file must be open and XFILE_SHARE_DENYWRITE must be set!
@parameters XFileInfo * pointer to an instance of XFileInfo
@returns    LONG                    result of the operatingsystem
*/
LONG XFile::GetFileInfo(XFileInfo * info)
{
   FILESTATUS3 buffer;

   LONG res = DosQueryFileInfo(handle, 1, &buffer, sizeof(buffer));
   if(res == 0)
   {
      char * p = (char*) &info->buffer;
      p += 4;
      memcpy( p, &buffer, sizeof(buffer));
   }
   return res;
}
コード例 #9
0
/*
** Determine the current size of a file in bytes
*/
static int os2FileSize( sqlite3_file *id, sqlite3_int64 *pSize ){
  APIRET rc = NO_ERROR;
  FILESTATUS3 fsts3FileInfo;
  memset(&fsts3FileInfo, 0, sizeof(fsts3FileInfo));
  assert( id!=0 );
  SimulateIOError( return SQLITE_IOERR_FSTAT );
  rc = DosQueryFileInfo( ((os2File*)id)->h, FIL_STANDARD, &fsts3FileInfo, sizeof(FILESTATUS3) );
  if( rc == NO_ERROR ){
    *pSize = fsts3FileInfo.cbFile;
    return SQLITE_OK;
  }else{
    return SQLITE_IOERR_FSTAT;
  }
}
コード例 #10
0
ファイル: syseautil.c プロジェクト: ErisBlastar/osfree
unsigned long SysGetEA(unsigned char *name,
                           unsigned long numargs,
                           RXSTRING args[],
                           char *queuename,
                           RXSTRING *retstr)
{
    long          rc;                      /* Ret code                   */
    unsigned char geabuff[300];            /* buffer for GEA             */
    unsigned long act;                     /* open action                */
    void          *fealist;                /* fealist buffer             */
    EAOP2         eaop;                    /* eaop structure             */
    PGEA2         pgea;                    /* pgea structure             */
    PFEA2         pfea;                    /* pfea structure             */
    HFILE         handle;                  /* file handle                */
    RXSTEMDATA    ldp;                     /* stem data                  */

    if (numargs != 3 || !RXVALIDSTRING(args[0]) ||
            !RXVALIDSTRING(args[1]) || !RXVALIDSTRING(args[2]))
            return INVALID_ROUTINE;

    ldp.count = 0;                       /* get the stem variable name */
    strcpy(ldp.varname, args[2].strptr);

    ldp.stemlen = args[2].strlength;
    strupr(ldp.varname);                 /* uppercase the name         */

    if (rc = DosOpen(args[0].strptr, &handle, &act,
            0L, 0, OPEN_ACTION_OPEN_IF_EXISTS,
            OPEN_ACCESS_READONLY + OPEN_SHARE_DENYREADWRITE +
            OPEN_FLAGS_FAIL_ON_ERROR + OPEN_FLAGS_WRITE_THROUGH,
            NULL)) {
        RETVAL(rc)
    }                                    /* get the file status info   */

    if (DosAllocMem((PPVOID)&fealist, 0x00010000L, AllocFlag)) {
        BUILDRXSTRING(retstr, ERROR_NOMEM);
        return VALID_ROUTINE;
    }
                                         /* FEA and GEA lists          */
    eaop.fpGEA2List = (PGEA2LIST)geabuff;
    eaop.fpFEA2List = (PFEA2LIST)fealist;
    eaop.oError = 0;                     /* no error occurred yet      */
    pgea = &eaop.fpGEA2List->list[0];    /* point to first GEA         */
    eaop.fpGEA2List->cbList = sizeof(ULONG) + sizeof(GEA2) +
        args[1].strlength;
    eaop.fpFEA2List->cbList = (ULONG)0xffff;

                                         /* fill in the EA name length */
    pgea->cbName = (BYTE)args[1].strlength;
    strcpy(pgea->szName, args[1].strptr);/* fill in the name           */
    pgea->oNextEntryOffset = 0;          /* fill in the next offset    */
                                         /* read the extended attribute*/
    rc = DosQueryFileInfo(handle, 3, (PSZ)&eaop, sizeof(EAOP2));
    DosClose(handle);                    /* close the file             */

    if (eaop.fpFEA2List->cbList <= sizeof(ULONG))
      rc = ERROR_EAS_NOT_SUPPORTED;      /* this is error also         */

    sprintf(retstr->strptr, "%d", rc);   /* format return code         */
    retstr->strlength = strlen(retstr->strptr);

    if (rc) {                            /* failure?                   */
        DosFreeMem(fealist);               /* error, get out             */
        return VALID_ROUTINE;
    }

    pfea = &(eaop.fpFEA2List->list[0]);  /* point to the first FEA     */
    ldp.shvb.shvnext = NULL;
    ldp.shvb.shvname.strptr = ldp.varname;
    ldp.shvb.shvname.strlength = ldp.stemlen;
    ldp.shvb.shvnamelen = ldp.stemlen;
    ldp.shvb.shvvalue.strptr = ((PSZ)pfea->szName+(pfea->cbName+1));
    ldp.shvb.shvvalue.strlength = pfea->cbValue;
    ldp.shvb.shvvaluelen = ldp.shvb.shvvalue.strlength;
    ldp.shvb.shvcode = RXSHV_SET;
    ldp.shvb.shvret = 0;
    if (RexxVariablePool(&ldp.shvb) == RXSHV_BADN) {
        DosFreeMem(fealist);               /* free our buffer            */
        return INVALID_ROUTINE;            /* error on non-zero          */
    }

    DosFreeMem(fealist);                 /* free our buffer            */

    return VALID_ROUTINE;
}
コード例 #11
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!
}
コード例 #12
0
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;
}
コード例 #13
0
ファイル: lxapid_cmd.c プロジェクト: OS2World/DRV-LXAPI32
//---------------------------- CMD_DosQueryFileInfo ----------------------------
void CMD_DosQueryFileInfo(HFILE hFile,LXIOCPA_DMN_CMDPARMPACKET* pParam
                          ,PLXDOSQUERYFILEINFOSTRUCT pfi)
{
 pParam->rc=DosQueryFileInfo(pfi->hFile,pfi->ulInfoLevel
                             ,&(pfi->filestatus),pfi->cbInfoBuf);
}
コード例 #14
0
ファイル: xprf.cpp プロジェクト: ErisBlastar/osfree
STATIC APIRET ReadINI(PXINI pXIni)      // in: profile opened with xprfOpenProfile
{
    APIRET      arc;
    FILESTATUS3 fs3;

    if (!(arc = DosQueryFileInfo(pXIni->hFile,
                                 FIL_STANDARD,
                                 &fs3,
                                 sizeof(fs3))))
    {
        PBYTE  pbFileData;
        if (!(pbFileData = (PBYTE)malloc(fs3.cbFile)))
            arc = ERROR_NOT_ENOUGH_MEMORY;
        else
        {
            ULONG ulSet = 0;

            if (!(arc = DosSetFilePtr(pXIni->hFile,
                                      0,
                                      FILE_BEGIN,
                                      &ulSet)))
            {
                ULONG cbRead = 0;
                if (!(arc = DosRead(pXIni->hFile,
                                    pbFileData,
                                    fs3.cbFile,
                                    &cbRead)))
                {
                    if (cbRead != fs3.cbFile)
                        arc = ERROR_NO_DATA;
                    else
                    {
                        PINIFILE_HEADER pHeader = (PINIFILE_HEADER)pbFileData;
                        if (pHeader->magic == 0xFFFFFFFF)
                        {
                            ULONG   ulAppOfs = pHeader->offFirstApp;

                            // create-applications loop
                            while ((ulAppOfs) && (!arc))
                            {
                                // application struct
                                PINIFILE_APP pApp = (PINIFILE_APP)(pbFileData + ulAppOfs);
                                ULONG   ulKeysOfs = pApp->offFirstKeyInApp;
                                PXINIAPPDATA pIniApp;

                                if (arc = CreateApp(pXIni,
                                                    (PCHAR)(pbFileData + pApp->offAppName),
                                                    &pIniApp))
                                    break;

                                // create-keys loop
                                while ((ulKeysOfs) && (!arc))
                                {
                                    PINIFILE_KEY pKey = (PINIFILE_KEY)(pbFileData + ulKeysOfs);

                                    PXINIKEYDATA pIniKey;

                                    if (arc = CreateKey(pIniApp,
                                                        (PSZ)(pbFileData + pKey->offKeyName),
                                                        (PBYTE)(pbFileData + pKey->offKeyData),
                                                        pKey->lenKeyData,
                                                        &pIniKey))
                                        break;

                                    // next key; can be null
                                    ulKeysOfs = pKey->offNextKeyInApp;
                                }

                                // next application; can be null
                                ulAppOfs = pApp->offNextApp;
                            }
                        }
                    }
                }
            }

            free(pbFileData);
        }
    }

    return arc;
}
コード例 #15
0
ファイル: ea.c プロジェクト: pgul/lgate
static int _ea_get (struct _ea *dst, char *path, int handle,
                    char *name)
{
  const void *fileref;
  ULONG rc, reftype, hf;
  EAOP2 eaop;
  PGEA2LIST pgealist;
  PFEA2LIST pfealist;
  PGEA2 pgea;
  PFEA2 pfea;
  int len, size;

  dst->flags = 0;
  dst->size = 0;
  dst->value = NULL;
  if (path != NULL)
    {
      reftype = ENUMEA_REFTYPE_PATH;
      fileref = path;
    }
  else
    {
      hf = handle;
      reftype = ENUMEA_REFTYPE_FHANDLE;
      fileref = &hf;
    }
  len = strlen (name);
  size = sizeof (GEA2LIST) + len;
  pgealist = alloca (size);
  pgealist->cbList = size;
  pgea = &pgealist->list[0];
  pgea->oNextEntryOffset = 0;
  pgea->cbName = len;
  memcpy (pgea->szName, name, len + 1);
  size = sizeof (FEA2LIST) + 0x10000;
  pfealist = malloc (size);
  pfealist->cbList = size;
  eaop.fpGEA2List = pgealist;
  eaop.fpFEA2List = pfealist;
  eaop.oError = 0;
  if (path == NULL)
    rc = DosQueryFileInfo (handle, FIL_QUERYEASFROMLIST, &eaop,
                           sizeof (eaop));
  else
    rc = DosQueryPathInfo (path, FIL_QUERYEASFROMLIST, &eaop,
                           sizeof (eaop));
  if (rc != 0)
    {
      _ea_set_errno (rc);
      free(pfealist);
      return -1;
    }
  pfea = &pfealist->list[0];
  if (pfea->cbValue != 0)
    {
      dst->value = malloc (pfea->cbValue);
      if (dst->value == NULL)
        {
          errno = ENOMEM;
          free(pfealist);
          return -1;
        }
      memcpy (dst->value, pfea->szName + pfea->cbName + 1, pfea->cbValue);
    }
  dst->flags = pfea->fEA;
  dst->size = pfea->cbValue;
  free(pfealist);
  return 0;
}
コード例 #16
0
 int main(VOID) {

 UCHAR        uchFileName[80] = "C:\\CONFIG.SYS";  /* File to manipulate    */

 FILESTATUS3  fsts3ConfigInfo = {{0}};       /* Buffer for file information */

 ULONG        ulBufSize     = sizeof(FILESTATUS3);  /* Size of above buffer */

 HFILE        hfConfig      = 0;             /* Handle for Config file      */

 ULONG        ulOpenAction  = 0;             /* Action taken by DosOpen     */

 APIRET       rc            = NO_ERROR;      /* Return code                 */



  rc = DosOpen(uchFileName,                 /* File to open (path and name) */

               &hfConfig,                /* File handle returned         */

               &ulOpenAction,               /* Action taken by DosOpen      */

               0L,0L,        /* Primary allocation and attributes (ignored) */

               OPEN_ACTION_FAIL_IF_NEW |

               OPEN_ACTION_OPEN_IF_EXISTS,  /* Open an existing file only   */

               OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY |

               OPEN_SHARE_DENYNONE,         /* Read access only             */

               0L);                         /* Extended attributes (ignored)*/



    if (rc != NO_ERROR) {

        printf("DosOpen error: return code = %u\n", rc);

        return 1;

    }



    rc = DosQueryFileInfo(hfConfig,   /* Handle of file                  */

                          FIL_STANDARD,  /* Request standard (Level 1) info */

                          &fsts3ConfigInfo, /* Buffer for file information  */

                          ulBufSize);    /* Size of buffer                  */

    if (rc != NO_ERROR) {

        printf("DosQueryFileInfo error: return code = %u\n", rc);

        return 1;

    }



    rc = DosClose(hfConfig);      /* Close the file  (check RC in real life) */

    printf("%s ---  File size: %u bytes\n",uchFileName, fsts3ConfigInfo.cbFile);

    printf("Last updated: %d/%d/%d; %d:%2.2d\n",

            fsts3ConfigInfo.fdateLastWrite.month,        /* Month            */

            fsts3ConfigInfo.fdateLastWrite.day,          /* Day              */

            (fsts3ConfigInfo.fdateLastWrite.year+1980L), /* Years since 1980 */

            fsts3ConfigInfo.ftimeLastWrite.hours,        /* Hours            */

            fsts3ConfigInfo.ftimeLastWrite.minutes);     /* Minutes          */



  return NO_ERROR;

}
コード例 #17
0
ファイル: localos2.c プロジェクト: Azarien/open-watcom-v2
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
}