本文整理汇总了C++中poco::File::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ File::getSize方法的具体用法?C++ File::getSize怎么用?C++ File::getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::File
的用法示例。
在下文中一共展示了File::getSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FileNotFoundException
SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void*):
_name(file.path()),
_memHandle(INVALID_HANDLE_VALUE),
_fileHandle(INVALID_HANDLE_VALUE),
_size(0),
_mode(PAGE_READONLY),
_address(0)
{
if (!file.exists() || !file.isFile())
throw FileNotFoundException(_name);
_size = static_cast<DWORD>(file.getSize());
DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
DWORD fileMode = GENERIC_READ;
if (mode == SharedMemory::AM_WRITE)
{
_mode = PAGE_READWRITE;
fileMode |= GENERIC_WRITE;
}
#if defined (POCO_WIN32_UTF8)
std::wstring utf16name;
UnicodeConverter::toUTF16(_name, utf16name);
_fileHandle = CreateFileW(utf16name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#else
_fileHandle = CreateFileA(_name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#endif
if (_fileHandle == INVALID_HANDLE_VALUE)
throw OpenFileException("Cannot open memory mapped file", _name);
_memHandle = CreateFileMapping(_fileHandle, NULL, _mode, 0, 0, NULL);
if (!_memHandle)
{
CloseHandle(_fileHandle);
_fileHandle = INVALID_HANDLE_VALUE;
throw SystemException("Cannot map file into shared memory", _name);
}
map();
}
示例2: FileNotFoundException
SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void* addrHint):
_size(0),
_fd(-1),
_address(0),
_access(mode),
_name(file.path()),
_fileMapped(true),
_server(false)
{
if (!file.exists() || !file.isFile())
throw FileNotFoundException(file.path());
_size = file.getSize();
int flag = O_RDONLY;
if (mode == SharedMemory::AM_WRITE)
flag = O_RDWR;
_fd = ::open(_name.c_str(), flag);
if (-1 == _fd)
throw OpenFileException("Cannot open memory mapped file", _name);
map(addrHint);
}
示例3: updateImpl
void FileChecker::updateImpl(const Poco::File & file)
{
map[Poco::Path(file.path()).getFileName()] = file.getSize();
}