newspeoplefor developersdocumentationdownloads

nFileServer2 Class Reference
[File I/O and File System Access]

#include <nfileserver2.h>

Inheritance diagram for nFileServer2:

nRoot nObject nNode nReferenced nSignalEmitter nNpkFileServer nRamFileServer List of all members.

Detailed Description

Central server object of Nebula2's file system subsystem. Provides functions for creating file and directory objects and assigns.

Please note that Nebula no longer knows the concept of a current working directory!

See also nFileServer2 Script Interface

(C) 2002 RadonLabs GmbH

Definition at line 31 of file nfileserver2.h.


Public Member Functions

 nFileServer2 ()
 constructor
virtual ~nFileServer2 ()
 destructor
bool SetAssign (const nString &assignName, const nString &pathName)
 sets a path alias
nString GetAssign (const nString &assignName)
 gets a path alias
void ResetAssigns ()
 Reset assign repository to default values.
nString ManglePath (const nString &pathName)
 expand path alias to real path
virtual bool MakePath (const nString &path)
 make path components
virtual bool CopyFile (const nString &from, const nString &to)
 copy a file
virtual bool DeleteFile (const nString &filename)
 delete a file
virtual bool DeleteDirectory (const nString &dirName)
 delete an empty directory
virtual bool Checksum (const nString &filename, uint &crc)
 compute the Crc checksum for a file
virtual void SetFileReadOnly (const nString &filename, bool readOnly)
 set read only status of a file
virtual bool IsFileReadOnly (const nString &filename)
 get read only status of a file
virtual nArray< nStringListFiles (const nString &dirName)
 list all files in a directory (ignores directories)
virtual nArray< nStringListMatchingFiles (const nString &dirName, const nString &pattern)
 list files in a directory matching pattern
virtual nArray< nStringListDirectories (const nString &dirName)
 list all subdirs in a directory (ignores files)
virtual nArray< nStringListMatchingDirectories (const nString &dirName, const nString &pattern)
 list subdirs in a directory matching pattern
virtual bool FileExists (const nString &pathName) const
 check if file exists
virtual int GetFileSize (const nString &pathName) const
 get file size
virtual bool DirectoryExists (const nString &pathName) const
 check if directory exists
virtual nFileTime GetFileWriteTime (const nString &pathName)
 return the time stamp when file was last written to
virtual nDirectoryNewDirectoryObject () const
 creates a new nDirectory object
virtual nFileNewFileObject () const
 creates a new nFile object
virtual nFileNodeCreateFileNode (const nString &name)
 creates a file node (only useful for scripting languages)
void ResetStatistics ()
 reset statistics
void AddBytesRead (int b)
 add read bytes
void AddBytesWritten (int b)
 add written bytes
void AddSeek ()
 add seek operation to stats
int GetBytesRead () const
 get bytes read since last reset
int GetBytesWritten () const
 get bytes written since last reset
int GetNumSeeks () const
 get number of seeks

Static Public Member Functions

static nFileServer2Instance ()
 get instance pointer

Protected Member Functions

void CleanupPathName (nString &str)
 cleanup a path name in place

Constructor & Destructor Documentation

nFileServer2::nFileServer2  ) 
 

constructor

history:

  • 30-Jan-2002 peter created

Definition at line 33 of file nfileserver2_main.cc.

nFileServer2::~nFileServer2  )  [virtual]
 

destructor

history:

  • 30-Jan-2002 peter created

Definition at line 61 of file nfileserver2_main.cc.


Member Function Documentation

nFileServer2 * nFileServer2::Instance  )  [inline, static]
 

get instance pointer

Definition at line 132 of file nfileserver2.h.

bool nFileServer2::SetAssign const nString assignName,
const nString pathName
 

sets a path alias

creates new or modifies existing assign under /sys/share/assigns

Parameters:
assignName the name of the assign
pathName the path to which the assign links
history:
  • 30-Jan-2002 peter created

Definition at line 78 of file nfileserver2_main.cc.

nString nFileServer2::GetAssign const nString assignName  ) 
 

gets a path alias

queries existing assign under /sys/share/assigns

Parameters:
assignName the name of the assign
Returns:
the path to which the assign links, or NULL if assign is undefined history:
  • 30-Jan-2002 peter created

Definition at line 109 of file nfileserver2_main.cc.

void nFileServer2::ResetAssigns  ) 
 

Reset assign repository to default values.

Remove all existing assigns and setup base assigns.

Definition at line 125 of file nfileserver2_main.cc.

nString nFileServer2::ManglePath const nString pathName  ) 
 

expand path alias to real path

Expands assign in path to full absolute path, replaces any backslashes by slashes, removes any trailing slash, and makes the path absolute.

Please note that Nebula does not know the concept of a current working directory, thus, all paths MUST be absolute (please note that Nebula assigns can be used to create position independent absolute paths).

Parameters:
pathName the path to expand
Returns:
resulting string
history:
  • 30-Jan-2002 peter created

Definition at line 205 of file nfileserver2_main.cc.

bool nFileServer2::MakePath const nString dirName  )  [virtual]
 

make path components

Make any missing directories in path.

Definition at line 560 of file nfileserver2_main.cc.

bool nFileServer2::CopyFile const nString from,
const nString to
[virtual]
 

copy a file

Copy a file. FIXME: the Non-Win32 version reads the entire file is into RAM!

  • 09-Mar-04 floh Win32 version now removes write protection on target file before copying.
  • 17-Oct-05 floh Win32 version now uses nFile so that the source can also live in an NPK archive

Definition at line 620 of file nfileserver2_main.cc.

bool nFileServer2::DeleteFile const nString filename  )  [virtual]
 

delete a file

Delete a file.

Definition at line 704 of file nfileserver2_main.cc.

bool nFileServer2::DeleteDirectory const nString dirName  )  [virtual]
 

delete an empty directory

Delete an empty directory.

Definition at line 722 of file nfileserver2_main.cc.

bool nFileServer2::Checksum const nString filename,
uint crc
[virtual]
 

compute the Crc checksum for a file

Compute the CRC checksum for a file. FIXME: the current implementation loads the entire file into memory.

Parameters:
filename [in] a Nebula filename
crc [out] the computed CRC checksum
Returns:
true if all ok, false if file could not be opened

Definition at line 766 of file nfileserver2_main.cc.

void nFileServer2::SetFileReadOnly const nString filename,
bool  readOnly
[virtual]
 

set read only status of a file

Set the read-only status of a file.

Definition at line 800 of file nfileserver2_main.cc.

bool nFileServer2::IsFileReadOnly const nString filename  )  [virtual]
 

get read only status of a file

Get the read-only status of a file. If the file does not exist, the routine returns false.

Definition at line 843 of file nfileserver2_main.cc.

nArray< nString > nFileServer2::ListFiles const nString dirName  )  [virtual]
 

list all files in a directory (ignores directories)

List all files in a directory, ignores subdirecories.

Definition at line 874 of file nfileserver2_main.cc.

nArray< nString > nFileServer2::ListMatchingFiles const nString dirName,
const nString pattern
[virtual]
 

list files in a directory matching pattern

List all files in a directory matching given pattern, ignores subdirectories.

Definition at line 899 of file nfileserver2_main.cc.

nArray< nString > nFileServer2::ListDirectories const nString dirName  )  [virtual]
 

list all subdirs in a directory (ignores files)

List all subdirectories in a directory, ignores files.

Definition at line 924 of file nfileserver2_main.cc.

nArray< nString > nFileServer2::ListMatchingDirectories const nString dirName,
const nString pattern
[virtual]
 

list subdirs in a directory matching pattern

List all subdirectories in a directory matching the given pattern, ignores files.

Definition at line 949 of file nfileserver2_main.cc.

bool nFileServer2::FileExists const nString pathName  )  const [virtual]
 

check if file exists

Definition at line 506 of file nfileserver2_main.cc.

int nFileServer2::GetFileSize const nString pathName  )  const [virtual]
 

get file size

Definition at line 523 of file nfileserver2_main.cc.

bool nFileServer2::DirectoryExists const nString pathName  )  const [virtual]
 

check if directory exists

Definition at line 541 of file nfileserver2_main.cc.

nFileTime nFileServer2::GetFileWriteTime const nString pathName  )  [virtual]
 

return the time stamp when file was last written to

Returns the timestamp when the file was last written to. If the file doesn't exist, a default nFileTime object will be returned.

Definition at line 975 of file nfileserver2_main.cc.

nDirectory * nFileServer2::NewDirectoryObject  )  const [virtual]
 

creates a new nDirectory object

creates a new nDirectory object

Returns:
the nDirectory object
history:
  • 30-Jan-2002 peter created

Reimplemented in nNpkFileServer.

Definition at line 242 of file nfileserver2_main.cc.

nFile * nFileServer2::NewFileObject  )  const [virtual]
 

creates a new nFile object

creates a new nFile object

Returns:
the nFile object
history:
  • 30-Jan-2002 peter created

Reimplemented in nNpkFileServer, and nRamFileServer.

Definition at line 259 of file nfileserver2_main.cc.

nFileNode * nFileServer2::CreateFileNode const nString name  )  [virtual]
 

creates a file node (only useful for scripting languages)

Create a filenode and return its full path name. A filenode is a nFile object wrapped into a nRoot subclass. It offers access to filesystem functionality for scripting languages which don't offer access to the host filesystem (like MicroTcl).

Definition at line 743 of file nfileserver2_main.cc.

void nFileServer2::ResetStatistics  )  [inline]
 

reset statistics

Reset statistics.

Definition at line 144 of file nfileserver2.h.

void nFileServer2::AddBytesRead int  b  )  [inline]
 

add read bytes

Add read bytes to statistics.

Definition at line 157 of file nfileserver2.h.

void nFileServer2::AddBytesWritten int  b  )  [inline]
 

add written bytes

Add read bytes written to statistics.

Definition at line 168 of file nfileserver2.h.

void nFileServer2::AddSeek  )  [inline]
 

add seek operation to stats

Add a seek op to stats.

Definition at line 179 of file nfileserver2.h.

int nFileServer2::GetBytesRead  )  const [inline]
 

get bytes read since last reset

Get bytes read since last ResetStatistics()

Definition at line 190 of file nfileserver2.h.

int nFileServer2::GetBytesWritten  )  const [inline]
 

get bytes written since last reset

Get bytes written since last ResetStatistics()

Definition at line 201 of file nfileserver2.h.

int nFileServer2::GetNumSeeks  )  const [inline]
 

get number of seeks

Get number of seeks since last ResetStatistics().

Definition at line 212 of file nfileserver2.h.

void nFileServer2::CleanupPathName nString str  )  [protected]
 

cleanup a path name in place

Returns a cleaned up path name (replaces backslashes with slashes, and removes trailing slash if exists.

Definition at line 135 of file nfileserver2_main.cc.


The documentation for this class was generated from the following files:

Copyright © 1999-2005 by the contributing authors. Ideas, requests, problems: Send feedback.