Mobile API Reference  MicroStrategy 2019
MFileSystem::File Class Reference

#include <File.h>

Classes

class  ReadSmartLock
 
class  WriteSmartLock
 

Public Types

enum  OpenMode {
  OPEN_MODE_READ, OPEN_MODE_WRITE_FROM_SCRATCH, OPEN_MODE_WRITE_APPEND, OPEN_MODE_UPDATE_EXISTING,
  OPEN_MODE_UPDATE_FROM_SCRATCH, OPEN_MODE_UPDATE_APPEND, OPEN_MODE_WRITE
}
 
enum  ShareMode { SHARE_MODE_DEFAULT, SHARE_MODE_NONE, SHARE_MODE_READ, SHARE_MODE_READ_AND_WRITE }
 

Static Public Member Functions

static void Move (const char *ipPathFrom, const char *ipPathTo)
 
static bool Delete (const char *ipPath)
 
static void Copy (const char *ipPathFrom, const char *ipPathTo, MDataType::Binary &irBinary)
 
static void Copy (const char *ipPathFrom, const char *ipPathTo)
 This method allocates a default-size buffer (~16KB). More...
 
static bool CopyAttributes (const char *ipPathFrom, const char *ipPathTo)
 This method copies file attributes. More...
 
static off_t GetSize (const char *ipPath)
 
static void GetLastModified (const char *ipPath, MDataType::DateTime &orDateTime)
 
static FILE * OpenStream (const char *ipPath, OpenMode iOpenMode, ShareMode iShareMode=SHARE_MODE_DEFAULT)
 
static void Copy (int iDescriptorFrom, int iDescriptorTo, MDataType::Binary &irBinary)
 
static void Copy (FILE *ipStreamFrom, FILE *ipStreamTo, MDataType::Binary &irBinary)
 
static void Copy (int iDescriptorFrom, const char *ipPathTo)
 This is a convenience method for backward compatibility. More...
 
static void Copy (FILE *ipStreamFrom, const char *ipPathTo)
 This is a convenience method for backward compatibility. More...
 
static off_t GetSize (int inDescriptor)
 
static off_t GetSize (FILE *ipStream)
 
static void Write (FILE *ipStream, const char *ipString, size_t iLength=0)
 
static void Write (FILE *ipStream, const void *ipData, size_t iByteLength)
 
static void Read (FILE *ipStream, MDataType::Binary &irBinary, size_t iMaxSize=0)
 
static void ReadLine (FILE *ipStream, MDataType::Binary &irBinary)
 
static void Flush (int iDescriptor)
 
static void Flush (FILE *ipStream)
 
static void Truncate (int iDescriptor, off_t iSize=0)
 
static void Truncate (FILE *ipStream, off_t iSize=0)
 
static off_t GetPosition (int iDescriptor)
 
static off_t GetPosition (FILE *ipStream)
 
static void MovePosition (int iDescriptor, off_t iOffset)
 
static void MovePosition (FILE *ipStream, off_t iOffset)
 
static void SetPosition (int iDescriptor, off_t iOffset)
 
static void SetPosition (FILE *ipStream, off_t iOffset)
 
static void CopyBlock (FILE *ipStream, MDataType::Binary &irBinary, off_t iTo, off_t iSize=0)
 

Static Protected Member Functions

static void WriteLock (int iDescriptor, bool bIsWait=true)
 
static void ReadLock (int iDescriptor, bool bIsWait=true)
 
static void Unlock (int iDescriptor) throw ()
 

Friends

class WriteSmartLock
 
class ReadSmartLock
 
class ReadableFileImpl
 
class WriteableFileImpl
 

Detailed Description

File contains functions operating upon a file.

Member Enumeration Documentation

◆ OpenMode

Defines a mode for opening a file.

The available modes correspond to the values of the second parameter to fopen(), which, in turn, translate into the low level file-open flags defined in <fcntl.h>.

See also
fopen()
open()
Enumerator
OPEN_MODE_READ 
OPEN_MODE_WRITE_FROM_SCRATCH 
OPEN_MODE_WRITE_APPEND 
OPEN_MODE_UPDATE_EXISTING 
OPEN_MODE_UPDATE_FROM_SCRATCH 
OPEN_MODE_UPDATE_APPEND 
OPEN_MODE_WRITE 

◆ ShareMode

Defines a mode for sharing a file with other processes.

Enumerator
SHARE_MODE_DEFAULT 
SHARE_MODE_NONE 
SHARE_MODE_READ 
SHARE_MODE_READ_AND_WRITE 

Member Function Documentation

◆ Copy() [1/6]

static void MFileSystem::File::Copy ( const char *  ipPathFrom,
const char *  ipPathTo,
MDataType::Binary irBinary 
)
static

Reads data from one descriptor/stream/path and writes that data into the other descriptor/stream using the Binary as a buffer.

Note: reading starts at the current position and continues until the end of file.

Parameters
iDescriptorFrom/ipStreamFrom/ipPathFromis the source.
iDescriptorTo/ipStreamTo/ipPathTois the destination.
irBinaryused as a buffer for copying.

◆ Copy() [2/6]

static void MFileSystem::File::Copy ( const char *  ipPathFrom,
const char *  ipPathTo 
)
static

This method allocates a default-size buffer (~16KB).

◆ Copy() [3/6]

static void MFileSystem::File::Copy ( int  iDescriptorFrom,
int  iDescriptorTo,
MDataType::Binary irBinary 
)
static

Reads data from one descriptor/stream/path and writes that data into the other descriptor/stream using the Binary as a buffer.

Note: reading starts at the current position and continues until the end of file.

Parameters
iDescriptorFrom/ipStreamFrom/ipPathFromis the source.
iDescriptorTo/ipStreamTo/ipPathTois the destination.
irBinaryused as a buffer for copying.

◆ Copy() [4/6]

static void MFileSystem::File::Copy ( FILE *  ipStreamFrom,
FILE *  ipStreamTo,
MDataType::Binary irBinary 
)
static

◆ Copy() [5/6]

static void MFileSystem::File::Copy ( int  iDescriptorFrom,
const char *  ipPathTo 
)
static

This is a convenience method for backward compatibility.

◆ Copy() [6/6]

static void MFileSystem::File::Copy ( FILE *  ipStreamFrom,
const char *  ipPathTo 
)
static

This is a convenience method for backward compatibility.

◆ CopyAttributes()

static bool MFileSystem::File::CopyAttributes ( const char *  ipPathFrom,
const char *  ipPathTo 
)
static

This method copies file attributes.

◆ CopyBlock()

static void MFileSystem::File::CopyBlock ( FILE *  ipStream,
MDataType::Binary irBinary,
off_t  iTo,
off_t  iSize = 0 
)
static

Copies the data block at current position to iTo preserving the data if source and destination locations overlap.

Parameters
iSizeis block size, if 0, the size is calculated as (file size - iFrom)
irBinaryused as a buffer for data copying

◆ Delete()

static bool MFileSystem::File::Delete ( const char *  ipPath)
static

Deletes a file. Does not throw any exceptions.

See also
MFileSystem::Directory::DeleteEmpty
Returns
true if deletion succeeded

◆ Flush() [1/2]

static void MFileSystem::File::Flush ( int  iDescriptor)
static

Flushes a file descriptor/stream.

◆ Flush() [2/2]

static void MFileSystem::File::Flush ( FILE *  ipStream)
static

◆ GetLastModified()

static void MFileSystem::File::GetLastModified ( const char *  ipPath,
MDataType::DateTime orDateTime 
)
static

Returns the UTC time of last modification.

◆ GetPosition() [1/2]

static off_t MFileSystem::File::GetPosition ( int  iDescriptor)
static

Returns the curent file position.

◆ GetPosition() [2/2]

static off_t MFileSystem::File::GetPosition ( FILE *  ipStream)
static

◆ GetSize() [1/3]

static off_t MFileSystem::File::GetSize ( const char *  ipPath)
static

Returns size of the specified file.

◆ GetSize() [2/3]

static off_t MFileSystem::File::GetSize ( int  inDescriptor)
static

Returns size of the specified file.

See also
OpenFileDescriptor( const char* )

◆ GetSize() [3/3]

static off_t MFileSystem::File::GetSize ( FILE *  ipStream)
static

◆ Move()

static void MFileSystem::File::Move ( const char *  ipPathFrom,
const char *  ipPathTo 
)
static

Moves a file/directory.

The function overwrites the target if it exists.

◆ MovePosition() [1/2]

static void MFileSystem::File::MovePosition ( int  iDescriptor,
off_t  iOffset 
)
static

Moves the file pointer relative to the current position.

◆ MovePosition() [2/2]

static void MFileSystem::File::MovePosition ( FILE *  ipStream,
off_t  iOffset 
)
static

Moves the file pointer relative to the current position. Also if successful, this method clears the end-of-file indicator and any prior ungetc calls with this stream.

◆ OpenStream()

static FILE* MFileSystem::File::OpenStream ( const char *  ipPath,
OpenMode  iOpenMode,
ShareMode  iShareMode = SHARE_MODE_DEFAULT 
)
static

Platform-independent way to open a file descriptor.

Note: on Windows, all files are opened in "binary" mode; the "text" mode is dead.

Use the file descriptor with *fstream classes defined in <fstream.h>, with their constructor.

Returns
a file descriptor, Exception is thrown if the operation failed.
See also
open() Platform-independent way to open a file stream.

Note: on Windows, all files are opened in "binary" mode; the "text" mode is dead.

Returns
pointer to FILE, Exception is thrown if the operation failed.
See also
fopen()

◆ Read()

static void MFileSystem::File::Read ( FILE *  ipStream,
MDataType::Binary irBinary,
size_t  iMaxSize = 0 
)
static

Read raw data from a file stream. GetSize method of irBinary returns the number of bytes read.

Parameters
iMaxSizehow many bytes to read, if 0 maximum capacity of irBinary is read.

◆ ReadLine()

static void MFileSystem::File::ReadLine ( FILE *  ipStream,
MDataType::Binary irBinary 
)
static

Read new-line delimited data from a file stream. The new-line character is preserved. If the last returned character is not '
', then there is more data to be read.

◆ ReadLock()

static void MFileSystem::File::ReadLock ( int  iDescriptor,
bool  bIsWait = true 
)
staticprotected

◆ SetPosition() [1/2]

static void MFileSystem::File::SetPosition ( int  iDescriptor,
off_t  iOffset 
)
static

Moves the file pointer to the absolute position.

◆ SetPosition() [2/2]

static void MFileSystem::File::SetPosition ( FILE *  ipStream,
off_t  iOffset 
)
static

Moves the file pointer to the absolute position. Also if successful, this method clears the end-of-file indicator and any prior ungetc calls with this stream.

◆ Truncate() [1/2]

static void MFileSystem::File::Truncate ( int  iDescriptor,
off_t  iSize = 0 
)
static

Truncates a file (changes file's size) to specified size.

◆ Truncate() [2/2]

static void MFileSystem::File::Truncate ( FILE *  ipStream,
off_t  iSize = 0 
)
static

◆ Unlock()

static void MFileSystem::File::Unlock ( int  iDescriptor)
throw (
)
staticprotected

◆ Write() [1/2]

static void MFileSystem::File::Write ( FILE *  ipStream,
const char *  ipString,
size_t  iLength = 0 
)
static

Writes a null-terminated character string into a file stream. If iLength is 0, the function writes ::strlen() characters, otherwise, it uses the provided value of iLength.

NOTE: it is required on most platforms to "flush" a buffered stream after writing and before reading/seeking. Otherwise, either SetPosition will fail, or the resulting file will be corrupt.

See also
MFileSystem::File::Flush
MFileSystem::File::SetPosition

◆ Write() [2/2]

static void MFileSystem::File::Write ( FILE *  ipStream,
const void *  ipData,
size_t  iByteLength 
)
static

Writes raw data into a file stream.

◆ WriteLock()

static void MFileSystem::File::WriteLock ( int  iDescriptor,
bool  bIsWait = true 
)
staticprotected

Friends And Related Function Documentation

◆ ReadableFileImpl

friend class ReadableFileImpl
friend

◆ ReadSmartLock

friend class ReadSmartLock
friend

◆ WriteableFileImpl

friend class WriteableFileImpl
friend

◆ WriteSmartLock

friend class WriteSmartLock
friend