Example #1
0
static int os2_open ( dvdcss_t dvdcss, const char *psz_device )
{
    char  psz_dvd[] = "X:";
    HFILE hfile;
    ULONG ulAction;
    ULONG rc;

    psz_dvd[0] = psz_device[0];

    rc = DosOpenL( ( PSZ )psz_dvd, &hfile, &ulAction, 0, FILE_NORMAL,
                   OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW,
                   OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_DASD,
                   NULL );

    if( rc )
    {
        print_error( dvdcss, "failed to open device %s", psz_device );
        return -1;
    }

    setmode( hfile, O_BINARY );

    dvdcss->i_fd = hfile;

    dvdcss->i_pos = 0;

    return 0;
}
Example #2
0
/* --------------------------------------------------------------------------
 Open a file according to the required opening mode.
 Display an error message in case of error.
- Parameters -------------------------------------------------------------
 PSZ pszFile : file name.
 LONGLONG cb : size of the file (used only when creating a new file).
 ULONG flag  : opening mode flag (see constants defined in fileUtil.h).
- Return value -----------------------------------------------------------
 HFILE : handle of the opened file or FMO_ERROR in case of error.
-------------------------------------------------------------------------- */
HFILE fmOpen(PSZ pszFile, LONGLONG cb, ULONG flag) {
   HFILE hf;
   ULONG ul;

   g.rc = DosOpenL(pszFile, &hf, &ul, cb, 0,
                   MKOPENFLAG(flag), MKOPENMODE(flag), NULL);
   if (g.mode & FSJVERBOSE)
      printMsg(IROW_DEBUG, SZ_FOPEN, pszFile, hf, g.rc);
   if (g.rc == 110) g.rc = ERROR_FILE_NOT_FOUND;
   if (g.rc)
      return (HFILE)handleFileIOError(FMO_ERROR, SZERR_OPENFILE, pszFile, g.rc);

   return hf;
}
Example #3
0
APIRET APIENTRY  DosOpen(PCSZ     pszFileName,
                         PHFILE pHf,
                         PULONG pulAction,
                         ULONG  cbFile,
                         ULONG  ulAttribute,
                         ULONG  fsOpenFlags,
                         ULONG  fsOpenMode,
                         PEAOP2 peaop2)
{
    LONGLONG cbFileL;
    cbFileL.ulLo=cbFile;
    cbFileL.ulHi=0;
    return DosOpenL(pszFileName, pHf, pulAction, cbFileL, ulAttribute, fsOpenFlags, fsOpenMode, peaop2);
}
Example #4
0
APIRET APIENTRY      PvtLoadMsgFile(PSZ pszFile, PVOID *buf, PULONG pcbFile)
{
  FILESTATUS3 fileinfo;
  HFILE    hf;
  ULONG    ulAction;
  LONGLONG ll;
  char     fn[CCHMAXPATH];
  ULONG    fisize;
  ULONG    ulActual;
  APIRET   rc;

  ll.ulLo = 0;
  ll.ulHi = 0;

  if (!pszFile || !*pszFile)
    return ERROR_INVALID_PARAMETER;

  if (strnlen(pszFile, CCHMAXPATH) == CCHMAXPATH)
    return ERROR_FILENAME_EXCED_RANGE;

  // try opening the file from the root dir/as is
  rc = DosOpenL(pszFile,                    // File name
                &hf,                        // File handle
                &ulAction,                  // Action
                ll,                         // Initial file size
                0,                          // Attributes
                OPEN_ACTION_FAIL_IF_NEW |   // Open type
                OPEN_ACTION_OPEN_IF_EXISTS,
                OPEN_SHARE_DENYNONE |       // Open mode
                OPEN_ACCESS_READONLY,
                NULL);                      // EA

  if (rc && rc != ERROR_FILE_NOT_FOUND &&
            rc != ERROR_OPEN_FAILED    &&
            rc != ERROR_PATH_NOT_FOUND)
    return rc;

  if (rc) // file not found
  {
    // if filename is fully qualified, return an error
    if (pszFile[1] ==':' && pszFile[2] == '\\')
      return rc;

    // otherwise, try searching in the currentdir and on path
    rc = DosSearchPath(SEARCH_IGNORENETERRS |
                       SEARCH_ENVIRONMENT   |
                       SEARCH_CUR_DIRECTORY,
                       "DPATH",
                       pszFile,
                       fn,
                       CCHMAXPATH);

    if (rc)
      return rc;

    // open it
    rc = DosOpenL(fn,
                  &hf,
                  &ulAction,
                  ll,
                  0,
                  OPEN_ACTION_FAIL_IF_NEW |
                  OPEN_ACTION_OPEN_IF_EXISTS,
                  OPEN_SHARE_DENYNONE |
                  OPEN_ACCESS_READONLY,
                  NULL);
  }

  if (rc)
    return rc;

  // file is found, so get file size
  rc = DosQueryPathInfo(fn,
                        FIL_STANDARD,
                        &fileinfo,
                        sizeof(FILESTATUS3));

  if (rc)
    return rc;

  if (!fileinfo.cbFile)
  {
    log("DosQueryPathInfo returned zero .msg file size!\n");
    return ERROR_INVALID_PARAMETER;
  }

  // allocate a buffer for the file
  rc = DosAllocMem(buf, fileinfo.cbFile,
                   PAG_READ | PAG_WRITE | PAG_COMMIT);

  if (rc)
    return rc;

  // read the file into memory
  rc = DosRead(hf,
               *buf,
               fileinfo.cbFile,
               &ulActual);

  if (rc)
    return rc;

  // close file
  DosClose(hf);
  *pcbFile = fileinfo.cbFile;

  return rc;
}