![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
#include <FileSystem.h>
Public Member Functions | |
| ~CFile () | |
| The destructor closes the file automatically. More... | |
| bool | Open (const std::string &filename, const std::string &mode) |
| Open a file. More... | |
| std::string | GetError () |
| Returns the last encountered error for this file. More... | |
| void | Close () |
| Close the file. More... | |
| int64_t | CurPos () |
| Returns current position in the file (ftell). More... | |
| int64_t | GetFileSize () |
| Returns the file size in bytes. More... | |
| int64_t | GetNumLines () |
| Returns the number of lines in the file. More... | |
| const char * | ReadLine () |
| template<class T > | |
| size_t | ReadData (T *data, size_t num_elems) |
| size_t | ReadData (void *data, size_t elem_size, size_t num_elems) |
| FILE * | GetFILE () |
| Returns the underlying C FILE pointer. More... | |
RAII Wrapper for C FILE* Throws exceptions in situations where the caller is not usually going to have proper handling code:
Definition at line 219 of file FileSystem.h.
| cloudViewer::utility::filesystem::CFile::~CFile | ( | ) |
The destructor closes the file automatically.
Definition at line 737 of file FileSystem.cpp.
References Close().
| void cloudViewer::utility::filesystem::CFile::Close | ( | ) |
| int64_t cloudViewer::utility::filesystem::CFile::CurPos | ( | ) |
Returns current position in the file (ftell).
Definition at line 760 of file FileSystem.cpp.
References GetError(), and LogError.
Referenced by GetFileSize(), cloudViewer::t::io::ReadPointCloudFromSPLAT(), cloudViewer::t::io::ReadPointCloudFromTXT(), cloudViewer::io::ReadPointCloudFromXYZ(), cloudViewer::t::io::ReadPointCloudFromXYZI(), cloudViewer::io::ReadPointCloudFromXYZN(), and cloudViewer::io::ReadPointCloudFromXYZRGB().
| std::string cloudViewer::utility::filesystem::CFile::GetError | ( | ) |
Returns the last encountered error for this file.
Definition at line 748 of file FileSystem.cpp.
References cloudViewer::utility::filesystem::GetIOErrorString().
Referenced by Close(), CurPos(), GetFileSize(), GetNumLines(), cloudViewer::t::io::ReadNpy(), cloudViewer::t::io::ReadNpz(), cloudViewer::t::io::NumpyArray::Save(), cloudViewer::t::io::WriteNpzEmpty(), and cloudViewer::t::io::WriteNpzOneTensor().
|
inline |
Returns the underlying C FILE pointer.
Definition at line 264 of file FileSystem.h.
Referenced by cloudViewer::t::io::ReadNpy(), cloudViewer::t::io::ReadNpz(), cloudViewer::t::io::ReadPointCloudFromPTS(), cloudViewer::t::io::NumpyArray::Save(), cloudViewer::t::io::WriteNpzEmpty(), cloudViewer::t::io::WriteNpzOneTensor(), cloudViewer::io::WritePointCloudToPTS(), cloudViewer::t::io::WritePointCloudToPTS(), cloudViewer::t::io::WritePointCloudToTXT(), cloudViewer::io::WritePointCloudToXYZ(), cloudViewer::t::io::WritePointCloudToXYZI(), cloudViewer::io::WritePointCloudToXYZN(), and cloudViewer::io::WritePointCloudToXYZRGB().
| int64_t cloudViewer::utility::filesystem::CFile::GetFileSize | ( | ) |
Returns the file size in bytes.
Definition at line 772 of file FileSystem.cpp.
References CurPos(), GetError(), LogError, SEEK_END, and size.
Referenced by cloudViewer::t::io::ReadPointCloudFromSPLAT(), cloudViewer::t::io::ReadPointCloudFromTXT(), cloudViewer::io::ReadPointCloudFromXYZ(), cloudViewer::t::io::ReadPointCloudFromXYZI(), cloudViewer::io::ReadPointCloudFromXYZN(), and cloudViewer::io::ReadPointCloudFromXYZRGB().
| int64_t cloudViewer::utility::filesystem::CFile::GetNumLines | ( | ) |
Returns the number of lines in the file.
Definition at line 793 of file FileSystem.cpp.
References GetError(), LogError, and SEEK_SET.
Referenced by cloudViewer::t::io::ReadPointCloudFromTXT(), and cloudViewer::t::io::ReadPointCloudFromXYZI().
| bool cloudViewer::utility::filesystem::CFile::Open | ( | const std::string & | filename, |
| const std::string & | mode | ||
| ) |
Open a file.
Definition at line 739 of file FileSystem.cpp.
References Close(), filename, and cloudViewer::utility::filesystem::FOpen().
Referenced by cloudViewer::t::io::DepthNoiseSimulator::DepthNoiseSimulator(), cloudViewer::t::io::ReadNpy(), cloudViewer::t::io::ReadNpz(), cloudViewer::io::ReadPointCloudFromPTS(), cloudViewer::t::io::ReadPointCloudFromPTS(), cloudViewer::t::io::ReadPointCloudFromSPLAT(), cloudViewer::t::io::ReadPointCloudFromTXT(), cloudViewer::io::ReadPointCloudFromXYZ(), cloudViewer::t::io::ReadPointCloudFromXYZI(), cloudViewer::io::ReadPointCloudFromXYZN(), cloudViewer::io::ReadPointCloudFromXYZRGB(), cloudViewer::t::io::NumpyArray::Save(), cloudViewer::t::io::WriteNpzEmpty(), cloudViewer::t::io::WriteNpzOneTensor(), cloudViewer::io::WritePointCloudToPTS(), cloudViewer::t::io::WritePointCloudToPTS(), cloudViewer::t::io::WritePointCloudToTXT(), cloudViewer::io::WritePointCloudToXYZ(), cloudViewer::t::io::WritePointCloudToXYZI(), cloudViewer::io::WritePointCloudToXYZN(), and cloudViewer::io::WritePointCloudToXYZRGB().
|
inline |
Read data to a buffer.
| data | The data buffer to be written into. |
| num_elements | Number of elements to be read. The byte size of the element is determined by the size of buffer type. |
Definition at line 253 of file FileSystem.h.
Referenced by cloudViewer::t::io::ReadPointCloudFromSPLAT().
| size_t cloudViewer::utility::filesystem::CFile::ReadData | ( | void * | data, |
| size_t | elem_size, | ||
| size_t | num_elems | ||
| ) |
Read data to a buffer.
| data | The data buffer to be written into. |
| elem_size | Element size in bytes. |
| num_elems | Number of elements to read. |
Definition at line 847 of file FileSystem.cpp.
References LogError.
| const char * cloudViewer::utility::filesystem::CFile::ReadLine | ( | ) |
Throws if we hit buffer maximum. In most cases, calling code is only capable of processing a complete line, if it receives a partial line it will probably fail and it is very likely to fail/corrupt on the next call that receives the remainder of the line.
Definition at line 820 of file FileSystem.cpp.
References DEFAULT_IO_BUFFER_SIZE, and LogError.
Referenced by cloudViewer::t::io::DepthNoiseSimulator::DepthNoiseSimulator(), cloudViewer::io::ReadPointCloudFromPTS(), cloudViewer::t::io::ReadPointCloudFromPTS(), cloudViewer::t::io::ReadPointCloudFromTXT(), cloudViewer::io::ReadPointCloudFromXYZ(), cloudViewer::t::io::ReadPointCloudFromXYZI(), cloudViewer::io::ReadPointCloudFromXYZN(), and cloudViewer::io::ReadPointCloudFromXYZRGB().