Example #1
0
BOOL FcbCreate(xfcb FAR * lpXfcb)
{
  sft FAR *sftp;
  COUNT sft_idx, FcbDrive;
  struct dhdr FAR *dhp;

  /* Build a traditional DOS file name                            */
  lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive);

  sft_idx = DosCreatSft(PriPathName, 0);
  if (sft_idx < 0)
      return FALSE;

  sftp = idx_to_sft(sft_idx);
  sftp->sft_attrib |= SFT_MFCB;  

  /* check for a device                                           */
  dhp = IsDevice(PriPathName);
  lpFcb->fcb_sftno = sft_idx;
  lpFcb->fcb_curec = 0;
  lpFcb->fcb_recsiz = (dhp ? 0 : 128);
  if (!dhp) lpFcb->fcb_drive = FcbDrive;
  lpFcb->fcb_fsize = 0;
  lpFcb->fcb_date = dos_getdate();
  lpFcb->fcb_time = dos_gettime();
  lpFcb->fcb_rndm = 0;
  return TRUE;
}
Example #2
0
BOOL FcbOpen(xfcb FAR * lpXfcb)
{
  sft FAR *sftp;
  struct dhdr FAR *dhp;
  COUNT FcbDrive, sft_idx;

  /* Build a traditional DOS file name                            */
  lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive);

  sft_idx = DosOpenSft(PriPathName, O_RDWR);
  if (sft_idx < 0)
      return FALSE;
  
  sftp = idx_to_sft(sft_idx);
  sftp->sft_attrib |= SFT_MFCB;
  
  /* check for a device                                           */
  lpFcb->fcb_curec = 0;
  lpFcb->fcb_rndm = 0;
  lpFcb->fcb_sftno = sft_idx;
  dhp = IsDevice(PriPathName);
  if (dhp )
  {
      lpFcb->fcb_recsiz = 0;
      lpFcb->fcb_fsize = 0;
      lpFcb->fcb_date = dos_getdate();
      lpFcb->fcb_time = dos_gettime();
  }
  else
  {
      lpFcb->fcb_drive = FcbDrive;
      lpFcb->fcb_recsiz = 128;
      lpFcb->fcb_fsize = sftp->sft_size;
      lpFcb->fcb_date = sftp->sft_date;
      lpFcb->fcb_time = sftp->sft_time;
  }
  return TRUE;
}
Example #3
0
COUNT DosOpen(BYTE FAR * fname, COUNT mode)
{
  psp FAR *p = MK_FP(cu_psp, 0);
  WORD hndl;
  WORD sft_idx;
  sft FAR *sftp;
  struct dhdr FAR *dhp;
  BYTE FAR *froot;
  WORD i;

  /* test if mode is in range                     */
  if ((mode & ~SFT_OMASK) != 0)
    return DE_INVLDACC;

  mode &= 3;
  /* get a free handle                            */
  if ((hndl = get_free_hndl()) == 0xff)
    return DE_TOOMANY;

  OpenMode = (BYTE) mode;

  /* now get a free system file table entry       */
  if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1)
    return DE_TOOMANY;

  /* check for a device                           */
  froot = get_root(fname);
  for (i = 0; i < FNAME_SIZE; i++)
  {
    if (*froot != '\0' && *froot != '.')
      PriPathName[i] = *froot++;
    else
      break;
  }

  for (; i < FNAME_SIZE; i++)
    PriPathName[i] = ' ';

  /* if we have an extension, can't be a device   */
  if (*froot != '.')
  {
    for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next)
    {
      if (fnmatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE))
      {
        sftp->sft_count += 1;
        sftp->sft_mode = mode;
        sftp->sft_attrib = 0;
        sftp->sft_flags =
            ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF;
        sftp->sft_psp = cu_psp;
        fbcopy((BYTE FAR *) PriPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE);
        sftp->sft_dev = dhp;
        sftp->sft_date = dos_getdate();
        sftp->sft_time = dos_gettime();

        p->ps_filetab[hndl] = sft_idx;
        return hndl;
      }
    }
  }

  if (Remote_OCT(REM_OPEN, fname, mode, sftp) == 0)
  {
    if (sftp->sft_flags & SFT_FSHARED)
    {
      sftp->sft_count += 1;
      p->ps_filetab[hndl] = sft_idx;
      return hndl;
    }
  }

  sftp->sft_status = dos_open(fname, mode);

  if (sftp->sft_status >= 0)
  {
    struct f_node FAR *fnp = xlt_fd(sftp->sft_status);

    sftp->sft_attrib = fnp->f_dir.dir_attrib;

    /* Check permissions. -- JPP */
    if ((sftp->sft_attrib & (D_DIR | D_VOLID)) ||
        ((sftp->sft_attrib & D_RDONLY) && (mode != O_RDONLY)))
    {
      return DE_ACCESS;
    }
    p->ps_filetab[hndl] = sft_idx;

    sftp->sft_count += 1;
    sftp->sft_mode = mode;
    sftp->sft_attrib = 0;
    sftp->sft_flags = 0;
    sftp->sft_psp = cu_psp;
    DosGetFile(fname, sftp->sft_name);
    return hndl;
  }
  else
    return sftp->sft_status;
}
Example #4
0
BOOL FcbOpen(xfcb FAR * lpXfcb)
{
  WORD sft_idx;
  sft FAR *sftp;
  struct dhdr FAR *dhp;
  COUNT FcbDrive;

  /* get a free system file table entry                           */
  if ((sftp = FcbGetFreeSft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1)
    return DE_TOOMANY;

  /* Build a traditional DOS file name                            */
  lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive);

  /* check for a device                                           */
  /* if we have an extension, can't be a device                   */
  if (IsDevice(PriPathName))
  {
    for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next)
    {
      if (FcbFnameMatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE))
      {
        sftp->sft_count += 1;
        sftp->sft_mode = O_RDWR;
        sftp->sft_attrib = 0;
        sftp->sft_flags =
            (dhp->dh_attr & ~SFT_MASK) | SFT_FDEVICE | SFT_FEOF;
        sftp->sft_psp = cu_psp;
        fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE);
        sftp->sft_dev = dhp;
        lpFcb->fcb_sftno = sft_idx;
        lpFcb->fcb_curec = 0;
        lpFcb->fcb_recsiz = 0;
        lpFcb->fcb_fsize = 0;
        lpFcb->fcb_date = dos_getdate();
        lpFcb->fcb_time = dos_gettime();
        lpFcb->fcb_rndm = 0;
        return TRUE;
      }
    }
  }
  sftp->sft_status = dos_open(PriPathName, O_RDWR);
  if (sftp->sft_status >= 0)
  {
    lpFcb->fcb_drive = FcbDrive;
    lpFcb->fcb_sftno = sft_idx;
    lpFcb->fcb_curec = 0;
    lpFcb->fcb_recsiz = 128;
    lpFcb->fcb_fsize = dos_getfsize(sftp->sft_status);
    dos_getftime(sftp->sft_status,
                 (date FAR *) & lpFcb->fcb_date,
                 (time FAR *) & lpFcb->fcb_time);
    lpFcb->fcb_rndm = 0;
    sftp->sft_count += 1;
    sftp->sft_mode = O_RDWR;
    sftp->sft_attrib = 0;
    sftp->sft_flags = 0;
    sftp->sft_psp = cu_psp;
    fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE);
    return TRUE;
  }
  else
    return FALSE;
}