//----------------------------------------------------------------------
//
//	FsDelete
//
//	Delete a file.
//
//----------------------------------------------------------------------
int
FsDelete (const char *name)
{
  // If file name starts with "dlx:", it's a DLX file system file.  Pass
  // the remainder of the file name to FsDlxDelete.
  if (!dstrncmp (name, "dlx:", 4)) {
    name += 4;			// Skip past the "dlx:"
    return (fs[1].Delete (name));
  } else {
    return (fs[0].Delete (name));
  }
}
Esempio n. 2
0
int DfsInodeFilenameExists(char *filename,int handle) {
   int i;
   int handler;
 //  printf("In DfsInodeFilename Exists\n");
   for (i=0; i<ENTRY_NUM;i++){
          if(dstrncmp(inodes[handle].dir[i].filename,filename,FILENAME_LENGTH) == 0){
            handler = inodes[handle].dir[i].inode; 
            return handler;
            }
       }
   return DFS_FAIL;
}
Esempio n. 3
0
const char *
dstrstr (const char *buf, const char *pattern)
{
  int	n = dstrlen (pattern);

  while (*buf != '\0') {
    if (dstrncmp (buf, pattern, n) == 0) {
      return (buf);
    }
    buf++;
  }
  return ((char *)0);
}
Esempio n. 4
0
//-----------------------------------------------------------------
// DfsInodeFilenameExists looks through all the inuse inodes for
// the given filename. If the filename is found, return the handle
// of the inode. If it is not found, return DFS_FAIL.
//-----------------------------------------------------------------
uint32 DfsInodeFilenameExists(char *filename) {
  uint32 i;
  if(!sb.valid) {
    printf("DfsInodeFilenameExists: invalid file system\n");
    return DFS_FAIL;
  }
  for(i = 0; i < sb.total_inodes; i++) {
    if(!inodes[i].valid) { continue; }
    if(dstrncmp(filename, inodes[i].filename, DFS_FILENAME_LENGTH) == 0) {
      return i;
    }
  }
  return DFS_FAIL;
}
Esempio n. 5
0
//----------------------------------------------------------------------
//
//	FsOpen
//
//	Open a file.  The name of the file is passed, along with the file
//	mode (read or write).
//
//	This function figures out which file system is desired using a
//	simple heuristic.  Basically, if the file starts with "dlx:", it's
//	a DLX file system file.  Otherwise, it's a UNIX file.
//
//	Once the file system is figured out, this routine allocates a
//	file descriptor and calls the file-system specific open routine.
//
//----------------------------------------------------------------------
int
FsOpen (const char *name, int mode)
{
  int		i, retval;

  dbprintf ('f', "Attepmting to open %s mode=%d.\n", name, mode);
  /* printf ("Attepmting to open %s mode=%d.\n", name, mode); */

  // Mask off all but the mode bits
  mode &= FS_MODE_RW;
  // ERROR if the caller hasn't specified a file mode.
  if (mode == 0) {
    printf("FsOpen: file mode unspecified!\n");
    return (-1);
  }
  for (i = 0; i < FS_MAX_OPEN_FILES; i++) {
    if (openfiles[i].flags == 0) {
      break;
    }
  }
  if (i >= FS_MAX_OPEN_FILES) {
    printf("FsOpen: no available open file structures!\n");
    return (-1);
  }
  openfiles[i].flags = mode;
  // If file name starts with "dlx:", it's a DLX file system file.  Pass
  // the remainder of the file name to FsDlxOpen.
  if (!dstrncmp (name, "dlx:", 4)) {
    name += 4;			// Skip past the "dlx:"
    openfiles[i].fs = 1;
  } else {
    openfiles[i].fs = 0;
  }
  dbprintf ('f', "File %s opening in file system %d.\n",name,openfiles[i].fs);

  /* printf ("File %s opening in file system %d.\n",name,openfiles[i].fs); */

  retval = fs[openfiles[i].fs].Open (i, name, mode);
  if (retval < 0) {
    // Open failed, so return error code
    printf("FsOpen: failed to open file with Open function pointer\n");
    FsFreeEntry (i);
    return (retval);
  }
  dbprintf ('f', "Opened %s in FS %d, mode=%d slot=%d.\n", name,
	    openfiles[i].fs, mode, i);
  return (i);
}
Esempio n. 6
0
void CON_CvarAutoComplete(char *partial)
{
    cvar_t*     cvar;
    int         len;
    char*       name = NULL;
    int         spacinglength;
    dboolean    match = false;
    char*       spacing = NULL;
    
    dstrlwr(partial);
    
    len = dstrlen(partial);
    
    if(!len)
        return;
    
    // check functions
    for(cvar = cvarcap; cvar; cvar = cvar->next)
    {
        if(!dstrncmp(partial, cvar->name, len))
        {
            if(!match)
            {
                match = true;
                CON_Printf(0, "\n");
            }

            name = cvar->name;

            // setup spacing
            spacinglength = 24 - dstrlen(cvar->name);
            spacing = Z_Malloc(spacinglength + 1, PU_STATIC, NULL);
            dmemset(spacing, 0x20, spacinglength);
            spacing[spacinglength] = 0;

            // print all matching cvars
            CON_Printf(AQUA, "%s%s= %s (%s)\n", name, spacing, cvar->string, cvar->defvalue);

            Z_Free(spacing);

            CONCLEARINPUT();
            sprintf(console_inputbuffer+1, "%s ", name);
            console_inputlength = dstrlen(console_inputbuffer);
        }
    }
}