AXCEL C++ Framework
Elegance through abstraction
Classes | Functions
axcel::fs Namespace Reference

File system. More...

Classes

class  file
 File. More...

Functions

timer fatime (const char *fname)
 Get file access time.
timer fmtime (const char *fname)
 Get file modification time.
bool mv (const char *src, const char *dst)
 Move file.
bool cp (const char *src, const char *dst)
 Copy file.
string gcd ()
 Get current directory.
string ls (const char *dir=0)
 List files.
size_t fread (const char *fname, char *buf, size_t len=0)
 Read from file.
string fread (const char *fname, size_t len=0)
 Read from text file.
size_t fwrite (const char *fname, const char *buf, size_t len=0)
 Write to file.
size_t fcat (const char *fname, const char *buf, size_t len=0)
 Concatenate to file.
bool fcmp (const char *src, const char *dst)
 Compare files.
bool md (const char *path)
 Make directory.
bool cd (const char *path)
 Change current directory.
bool creat (const char *fname)
 Create file.
bool trunc (const char *fname, unsigned long len)
 Resize file.
bool rm (const char *fname)
 Remove file.
bool rd (const char *dir, bool rmsub=1)
 Remove directory.
size_t fsize (const char *fname)
 Get file size.
bool fexist (const char *fname)
 Check if file exists.
bool fisdir (const char *fname)
 Check if file is directory.
bool fisreg (const char *fname)
 Check if file is regular file.
data fbread (const char *fname, size_t len=0)
 Read binary data from file.
size_t fbwrite (const char *fname, data d, size_t len=0)
 Write binary data to file.
string tmpnam ()
 Generate temporary filename.

Detailed Description

File system.


Function Documentation

bool axcel::fs::cd ( const char *  path)

Change current directory.

Parameters:
pathAbsolute path or path relative to current directory
Returns:
true success, false failure

Definition at line 5704 of file axcel.cpp.

bool axcel::fs::cp ( const char *  src,
const char *  dst 
)

Copy file.

Parameters:
srcfile to copy from
dstfile or folder to copy to
Returns:
true success, false failure

Definition at line 5549 of file axcel.cpp.

bool axcel::fs::creat ( const char *  fname)

Create file.

Parameters:
fnameAbsolute or relative pathname of file
Returns:
true success, false failure

Definition at line 5705 of file axcel.cpp.

timer axcel::fs::fatime ( const char *  fname)

Get file access time.

Parameters:
fnameAbsolute or relative path of file
Returns:
timer object containing last file access time as localtime

Definition at line 5475 of file axcel.cpp.

data axcel::fs::fbread ( const char *  fname,
size_t  len = 0 
)

Read binary data from file.

Definition at line 1358 of file axcel.cpp.

size_t axcel::fs::fbwrite ( const char *  fname,
data  d,
size_t  len = 0 
)

Write binary data to file.

Definition at line 1368 of file axcel.cpp.

size_t axcel::fs::fcat ( const char *  fname,
const char *  buf,
size_t  len = 0 
)

Concatenate to file.

Parameters:
fnameAbsolute or relative path of file
bufBuffer to write from
lenNumber of bytes to write (0 for all until '\0')
Returns:
Number of bytes read

Definition at line 5669 of file axcel.cpp.

bool axcel::fs::fcmp ( const char *  src,
const char *  dst 
)

Compare files.

Parameters:
srcAbsolute or relative path of a file
dstAbsolute or relative path of another file
Returns:
true if both are of same content, false if not

Definition at line 5678 of file axcel.cpp.

bool axcel::fs::fexist ( const char *  fname)

Check if file exists.

Parameters:
fnameAbsolute or relative path of file
Returns:
true if file exists, false if not

Definition at line 5741 of file axcel.cpp.

bool axcel::fs::fisdir ( const char *  fname)

Check if file is directory.

Parameters:
fnameAbsolute or relative path of file
Returns:
true if directory, false if not

Definition at line 5748 of file axcel.cpp.

bool axcel::fs::fisreg ( const char *  fname)

Check if file is regular file.

Parameters:
fnameAbsolute or relative path of file
Returns:
true if regular file, false if not

Definition at line 5753 of file axcel.cpp.

timer axcel::fs::fmtime ( const char *  fname)

Get file modification time.

Parameters:
fnameAbsolute or relative path of file
Returns:
timer object containing last file modification time as localtime

Definition at line 5482 of file axcel.cpp.

string axcel::fs::fread ( const char *  fname,
size_t  len = 0 
)

Read from text file.

Parameters:
fnameAbsolute or relative path of file
lenNumber of bytes to read (0 for all)
Returns:
string object containing read bytes

Definition at line 5645 of file axcel.cpp.

size_t axcel::fs::fread ( const char *  fname,
char *  buf,
size_t  len = 0 
)

Read from file.

Parameters:
fnameAbsolute or relative path of file
bufBuffer to read into
lenNumber of bytes to read (0 for all)
Returns:
Number of bytes read

Definition at line 5633 of file axcel.cpp.

size_t axcel::fs::fsize ( const char *  fname)

Get file size.

Parameters:
fnameAbsolute or relative path of file
Returns:
Size of file in bytes

Definition at line 5736 of file axcel.cpp.

size_t axcel::fs::fwrite ( const char *  fname,
const char *  buf,
size_t  len = 0 
)

Write to file.

Parameters:
fnameAbsolute or relative path of file
bufBuffer to write from
lenNumber of bytes to write (0 for all until '\0')
Returns:
Number of bytes read

Definition at line 5660 of file axcel.cpp.

string axcel::fs::gcd ( )

Get current directory.

Returns:
string object containing absolute pathname of the current working directory

Definition at line 5592 of file axcel.cpp.

string axcel::fs::ls ( const char *  dir = 0)

List files.

Parameters:
dirDirectory to list
Returns:
string containing directory's contents.

List files/folders in directory dir. If dir is not specified, the current directory is used. The string returned contains each file/folder in the directory delimited by a '\n' character.

Definition at line 5607 of file axcel.cpp.

bool axcel::fs::md ( const char *  path)

Make directory.

Parameters:
pathRelative or absolute path of folder
Returns:
true success, false failure

Definition at line 5703 of file axcel.cpp.

bool axcel::fs::mv ( const char *  src,
const char *  dst 
)

Move file.

Parameters:
srcfile to move
dstDestination file or folder
Returns:
true success, false failure

Definition at line 5547 of file axcel.cpp.

bool axcel::fs::rd ( const char *  dir,
bool  rmsub = 1 
)

Remove directory.

Parameters:
dirRelative or absolute path of folder
rmsubRecursively remove or only remove if empty
Returns:
true success, false failure

If rmsub is true, then this function recursively deletes all child files and folders. If rmsub is false, this function only removes the specified directory if it is empty.

Definition at line 5717 of file axcel.cpp.

bool axcel::fs::rm ( const char *  fname)

Remove file.

Parameters:
fnameRelative or absolute path of file
Returns:
true success, false failure

Definition at line 5715 of file axcel.cpp.

string axcel::fs::tmpnam ( )

Generate temporary filename.

Returns:
Unique temporary filename

Definition at line 229 of file axcel.cpp.

bool axcel::fs::trunc ( const char *  fname,
unsigned long  len 
)

Resize file.

Parameters:
fnameAbsolute or relative pathname of file
lenNew length of file in bytes
Returns:
true success, false failure

Cause the regular file named by fname to be truncated to a size of precisely len bytes. If the file previously was larger than this size, the extra data is lost. If the file previously was shorter, it is extended, and the extended part reads as null bytes ('\0').

Definition at line 5711 of file axcel.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerator Defines