AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
AJAFileIO Class Reference

#include <file_io.h>

Inheritance diagram for AJAFileIO:
[legend]

Public Member Functions

 AJAFileIO ()
 
 ~AJAFileIO ()
 
AJAStatus Open (const std::string &fileName, const int flags, const int properties)
 
AJAStatus Open (const std::wstring &fileName, const int flags, const int properties)
 
AJAStatus Close ()
 
bool IsOpen ()
 
uint32_t Read (uint8_t *pBuffer, const uint32_t length)
 
uint32_t Read (std::string &buffer, const uint32_t length)
 
uint32_t Write (const uint8_t *pBuffer, const uint32_t length) const
 
uint32_t Write (const std::string &buffer) const
 
AJAStatus Sync ()
 
AJAStatus Truncate (int32_t offset)
 
int64_t Tell ()
 
AJAStatus Seek (const int64_t distance, const AJAFileSetFlag flag) const
 
AJAStatus FileInfo (int64_t &createTime, int64_t &modTime, int64_t &size)
 
AJAStatus FileInfo (int64_t &createTime, int64_t &modTime, int64_t &size, std::string &filePath)
 
void SetHandle (FILE *fp)
 
void * GetHandle (void)
 

Static Public Member Functions

static bool FileExists (const std::wstring &fileName)
 
static bool FileExists (const std::string &fileName)
 
static AJAStatus Delete (const std::string &fileName)
 
static AJAStatus Delete (const std::wstring &fileName)
 
static AJAStatus ReadDirectory (const std::string &directory, const std::string &filePattern, std::vector< std::string > &fileContainer)
 
static AJAStatus ReadDirectory (const std::wstring &directory, const std::wstring &filePattern, std::vector< std::wstring > &fileContainer)
 
static AJAStatus DoesDirectoryContain (const std::string &directory, const std::string &filePattern)
 
static AJAStatus DoesDirectoryContain (const std::wstring &directory, const std::wstring &filePattern)
 
static AJAStatus DoesDirectoryExist (const std::string &directory)
 
static AJAStatus DoesDirectoryExist (const std::wstring &directory)
 
static bool DirectoryExists (const std::string &directory)
 
static bool DirectoryExists (const std::wstring &directory)
 
static AJAStatus IsDirectoryEmpty (const std::string &directory)
 
static AJAStatus IsDirectoryEmpty (const std::wstring &directory)
 
static AJAStatus TempDirectory (std::string &directory)
 
static AJAStatus TempDirectory (std::wstring &directory)
 
static AJAStatus GetWorkingDirectory (std::string &directory)
 
static AJAStatus GetWorkingDirectory (std::wstring &directory)
 
static AJAStatus GetDirectoryName (const std::string &path, std::string &directory)
 
static AJAStatus GetDirectoryName (const std::wstring &path, std::wstring &directory)
 
static AJAStatus GetFileName (const std::string &path, std::string &filename)
 
static AJAStatus GetFileName (const std::wstring &path, std::wstring &filename)
 
static AJAStatus GetExecutablePath (std::string &path)
 
static AJAStatus GetExecutablePath (std::wstring &path)
 

Detailed Description

The File I/O class proper.

Definition at line 64 of file file_io.h.

Constructor & Destructor Documentation

◆ AJAFileIO()

AJAFileIO::AJAFileIO ( )

Definition at line 73 of file file_io.cpp.

◆ ~AJAFileIO()

AJAFileIO::~AJAFileIO ( )

Definition at line 90 of file file_io.cpp.

Member Function Documentation

◆ Close()

AJAStatus AJAFileIO::Close ( )

Close a file.

Returns
AJA_STATUS_SUCCESS The file was successfully closed AJA_STATUS_FAIL The file could not be closed

Definition at line 281 of file file_io.cpp.

◆ Delete() [1/2]

static AJAStatus AJAFileIO::Delete ( const std::string &  fileName)
static

Remove the file from the system

Parameters
[in]fileNameThe fully qualified file name
Returns
AJA_STATUS_SUCCESS The file was successfully deleteed AJA_STATUS_FAIL The file could not be deleted

◆ Delete() [2/2]

static AJAStatus AJAFileIO::Delete ( const std::wstring &  fileName)
static

◆ DirectoryExists() [1/2]

bool AJAFileIO::DirectoryExists ( const std::string &  directory)
static

Tests if a directory exists. Does not change the current directory.

Parameters
[in]directoryThe path to the directory
Returns
true If and only if the directory exists

Definition at line 1113 of file file_io.cpp.

◆ DirectoryExists() [2/2]

bool AJAFileIO::DirectoryExists ( const std::wstring &  directory)
static

Definition at line 1119 of file file_io.cpp.

◆ DoesDirectoryContain() [1/2]

AJAStatus AJAFileIO::DoesDirectoryContain ( const std::string &  directory,
const std::string &  filePattern 
)
static

Tests if a directory contains a file that matches the pattern. Does not change the current directory.

Parameters
[in]directoryThe path to the directory
[in]filePatternThe pattern within the directory to match
Returns
AJA_STATUS_SUCCESS If the directory has at least one matching file

Definition at line 974 of file file_io.cpp.

◆ DoesDirectoryContain() [2/2]

AJAStatus AJAFileIO::DoesDirectoryContain ( const std::wstring &  directory,
const std::wstring &  filePattern 
)
static

Definition at line 1025 of file file_io.cpp.

◆ DoesDirectoryExist() [1/2]

AJAStatus AJAFileIO::DoesDirectoryExist ( const std::string &  directory)
static

Tests if a directory exists. Does not change the current directory.

Parameters
[in]directoryThe path to the directory
Returns
AJA_STATUS_SUCCESS If and only if the directory exists

Definition at line 1070 of file file_io.cpp.

◆ DoesDirectoryExist() [2/2]

AJAStatus AJAFileIO::DoesDirectoryExist ( const std::wstring &  directory)
static

Definition at line 1095 of file file_io.cpp.

◆ FileExists() [1/2]

bool AJAFileIO::FileExists ( const std::string &  fileName)
static

Definition at line 114 of file file_io.cpp.

◆ FileExists() [2/2]

bool AJAFileIO::FileExists ( const std::wstring &  fileName)
static

Test file to see if it exists

Parameters
[in]fileNameThe fully qualified file name
Returns
bool true if file exists

Definition at line 97 of file file_io.cpp.

◆ FileInfo() [1/2]

AJAStatus AJAFileIO::FileInfo ( int64_t &  createTime,
int64_t &  modTime,
int64_t &  size 
)

Get some basic file info

Parameters
[out]createTimeTime of file creation, measured in seconds since 1970
[out]modTimeLast time file was modified, measured in seconds since 1970
[out]sizeSize of the file in bytes
Returns
AJA_STATUS_SUCCESS Was able to get info from the file

Definition at line 627 of file file_io.cpp.

◆ FileInfo() [2/2]

AJAStatus AJAFileIO::FileInfo ( int64_t &  createTime,
int64_t &  modTime,
int64_t &  size,
std::string &  filePath 
)

Definition at line 639 of file file_io.cpp.

◆ GetDirectoryName() [1/2]

AJAStatus AJAFileIO::GetDirectoryName ( const std::string &  path,
std::string &  directory 
)
static

Retrieves the directory name from the specified path.

Parameters
[in]pathPath from which to extract the directory name
[out]directoryPath of the directory extracted from specified path
Returns
AJA_STATUS_SUCCESS If and only if the directory name is extracted

Definition at line 1301 of file file_io.cpp.

◆ GetDirectoryName() [2/2]

AJAStatus AJAFileIO::GetDirectoryName ( const std::wstring &  path,
std::wstring &  directory 
)
static

Definition at line 1316 of file file_io.cpp.

◆ GetExecutablePath() [1/2]

AJAStatus AJAFileIO::GetExecutablePath ( std::string &  path)
static

Retrieves the full path of the currently running exectuable.

Parameters
[out]pathPath of the running executable
Returns
AJA_STATUS_SUCCESS If and only if the executable path is retrieved

Definition at line 1361 of file file_io.cpp.

◆ GetExecutablePath() [2/2]

AJAStatus AJAFileIO::GetExecutablePath ( std::wstring &  path)
static

Definition at line 1392 of file file_io.cpp.

◆ GetFileName() [1/2]

AJAStatus AJAFileIO::GetFileName ( const std::string &  path,
std::string &  filename 
)
static

Retrieves the filename (with extension) from the specified path.

Parameters
[in]pathPath from which to extract the filename
[out]filenameFilename extracted from specified path
Returns
AJA_STATUS_SUCCESS If and only if the filename is extracted

Definition at line 1331 of file file_io.cpp.

◆ GetFileName() [2/2]

AJAStatus AJAFileIO::GetFileName ( const std::wstring &  path,
std::wstring &  filename 
)
static

Definition at line 1346 of file file_io.cpp.

◆ GetHandle()

void* AJAFileIO::GetHandle ( void  )
inline

Definition at line 344 of file file_io.h.

◆ GetWorkingDirectory() [1/2]

AJAStatus AJAFileIO::GetWorkingDirectory ( std::string &  directory)
static

Retrieves the path to the current working directory

Parameters
[out]directoryPath of the current working directory
Returns
AJA_STATUS_SUCCESS If and only if current working directory retrieved.

Definition at line 1269 of file file_io.cpp.

◆ GetWorkingDirectory() [2/2]

AJAStatus AJAFileIO::GetWorkingDirectory ( std::wstring &  directory)
static

Definition at line 1288 of file file_io.cpp.

◆ IsDirectoryEmpty() [1/2]

AJAStatus AJAFileIO::IsDirectoryEmpty ( const std::string &  directory)
static

Tests if a directory is empty. Does not change the current directory.

Parameters
[in]directoryThe path to the directory
Returns
AJA_STATUS_SUCCESS If and only if the directory contains no files

Definition at line 1126 of file file_io.cpp.

◆ IsDirectoryEmpty() [2/2]

AJAStatus AJAFileIO::IsDirectoryEmpty ( const std::wstring &  directory)
static

Definition at line 1146 of file file_io.cpp.

◆ IsOpen()

bool AJAFileIO::IsOpen ( )

Tests for a valid open file.

Returns
bool 'true' if a valid file is available

Definition at line 317 of file file_io.cpp.

◆ Open() [1/2]

AJAStatus AJAFileIO::Open ( const std::string &  fileName,
const int  flags,
const int  properties 
)

Open a file.

Parameters
[in]fileNameThe fully qualified file name
[in]flagsThe way in which the file is opened
[in]propertiesIndicates whether the file is buffered or not
Returns
AJA_STATUS_SUCCESS A file has been successfully opened AJA_STATUS_FAIL A file could not be opened

Definition at line 201 of file file_io.cpp.

◆ Open() [2/2]

AJAStatus AJAFileIO::Open ( const std::wstring &  fileName,
const int  flags,
const int  properties 
)

Definition at line 131 of file file_io.cpp.

◆ Read() [1/2]

uint32_t AJAFileIO::Read ( std::string &  buffer,
const uint32_t  length 
)

Read the contents of the file.

Parameters
[out]bufferThe buffer to be written to
[in]lengthThe number of bytes to be read
Returns
uint32_t The number of bytes actually read

Definition at line 360 of file file_io.cpp.

◆ Read() [2/2]

uint32_t AJAFileIO::Read ( uint8_t *  pBuffer,
const uint32_t  length 
)

Read the contents of the file.

Parameters
[out]pBufferThe buffer to be written to
[in]lengthThe number of bytes to be read
Returns
uint32_t The number of bytes actually read

Definition at line 328 of file file_io.cpp.

◆ ReadDirectory() [1/2]

AJAStatus AJAFileIO::ReadDirectory ( const std::string &  directory,
const std::string &  filePattern,
std::vector< std::string > &  fileContainer 
)
static

Retrieves a set of files from a directory. Changes the current directory.

Parameters
[in]directoryThe path to the directory
[in]filePatternThe pattern within the directory to match
[out]fileContainerThe files that match the file pattern
Returns
AJA_STATUS_SUCCESS The returned container has a size > 0

Definition at line 805 of file file_io.cpp.

◆ ReadDirectory() [2/2]

AJAStatus AJAFileIO::ReadDirectory ( const std::wstring &  directory,
const std::wstring &  filePattern,
std::vector< std::wstring > &  fileContainer 
)
static

Definition at line 912 of file file_io.cpp.

◆ Seek()

AJAStatus AJAFileIO::Seek ( const int64_t  distance,
const AJAFileSetFlag  flag 
) const

Moves the offset of the file pointer.

Parameters
[in]distanceThe distance to move the file pointer
[in]flagDescribes from whence to move the file pointer
Returns
AJA_STATUS_SUCCESS The position of the file pointer was moved

Definition at line 545 of file file_io.cpp.

◆ SetHandle()

void AJAFileIO::SetHandle ( FILE *  fp)

Set private file handle from FILE pointer.

Parameters
[in]fpThe FILE pointer

Definition at line 1415 of file file_io.cpp.

◆ Sync()

AJAStatus AJAFileIO::Sync ( )

Flush the cache

Returns
AJA_STATUS_SUCCESS Was able to sync file

Definition at line 430 of file file_io.cpp.

◆ Tell()

int64_t AJAFileIO::Tell ( )

Retrieves the offset of the file pointer from the start of a file.

Returns
int64_t The position of the file pointer, -1 if error

Definition at line 503 of file file_io.cpp.

◆ TempDirectory() [1/2]

AJAStatus AJAFileIO::TempDirectory ( std::string &  directory)
static

Retrieves a path to the temp directory

Parameters
[out]directoryThe path to the temp directory
Returns
AJA_STATUS_SUCCESS If and only if a temp directory found

Definition at line 1166 of file file_io.cpp.

◆ TempDirectory() [2/2]

AJAStatus AJAFileIO::TempDirectory ( std::wstring &  directory)
static

Definition at line 1230 of file file_io.cpp.

◆ Truncate()

AJAStatus AJAFileIO::Truncate ( int32_t  offset)

Truncates the file.

Parameters
[in]offsetThe size offset of the file
Returns
AJA_STATUS_SUCCESS Was able to truncate file

Definition at line 459 of file file_io.cpp.

◆ Write() [1/2]

uint32_t AJAFileIO::Write ( const std::string &  buffer) const

Write the contents of the file.

Parameters
[in]bufferThe buffer to be written out
Returns
uint32_t The number of bytes actually written

Definition at line 419 of file file_io.cpp.

◆ Write() [2/2]

uint32_t AJAFileIO::Write ( const uint8_t *  pBuffer,
const uint32_t  length 
) const

Write the contents of the file.

Parameters
[in]pBufferThe buffer to be written out
[in]lengthThe number of bytes to be written
Returns
uint32_t The number of bytes actually written

Definition at line 380 of file file_io.cpp.


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