YSTest: File.cpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

File.cpp
浏览该文件的文档.
1 /*
2 © 2009-2017 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #include "YSLib/Service/YModules.h"
29 #include YFM_YSLib_Service_File
30
31 namespace YSLib
32 {
33
34 namespace IO
35 {
36
37 UniqueFile
38 OpenFile(const char* filename, int omode, mode_t pmode)
39 {
40 if(UniqueFile p_ifile{uopen(filename, omode, pmode)})
41 return p_ifile;
42 else
43 ystdex::throw_error(errno, "Failed opening file '" + string(filename)
44 + '\'');
45 }
46
47
48 SharedInputMappedFileStream::SharedInputMappedFileStream(const char* path)
49 : MappedFile(path), SharedIndirectLockGuard<const UniqueFile>(
50 GetUniqueFile()), ystdex::membuf(ystdex::replace_cast<const char*>(
51 GetPtr()), GetSize()), std::istream(this)
52 {}
53
54 ImplDeDtor(SharedInputMappedFileStream)
55
56
57 UniqueLockedOutputFileStream::UniqueLockedOutputFileStream(int fd)
58 : ofstream(UniqueFile(fd)), desc(fd), lock()
59 {
60 if(*this)
61 lock = unique_lock<FileDescriptor>(desc);
62 }
63 UniqueLockedOutputFileStream::UniqueLockedOutputFileStream(UniqueFile ufile)
64 : UniqueLockedOutputFileStream(*ufile.get())
65 {
66 ufile.release();
67 }
68
69 ImplDeDtor(UniqueLockedOutputFileStream)
70
71 } // namespace IO;
72
73 } // namespace YSLib;
74
YModules.h
YSLib::IO::mode_t
YF_API mode_t
Definition: File.h:51
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::ImplDeDtor
ImplDeDtor(LoggedEvent) FatalError
Definition: YException.cpp:47
ystdex::replace_cast
ystdex::enable_if_t< and_< is_object_pointer< _pDst >, is_trivially_replaceable< _tSrc, remove_pointer_t< _pDst > > >::value, _pDst > replace_cast(_tSrc *v)
保证平凡替换存储的显式转换。
Definition: type_pun.hpp:204
platform::UniqueFile
unique_ptr_from< FileDescriptor::Deleter > UniqueFile
Definition: FileIO.h:464
platform::uopen
int uopen(const char *filename, int oflag, mode_t pmode) ynothrowv
Definition: FileIO.cpp:873
ystdex::membuf
basic_membuf< char > membuf
Definition: streambuf.hpp:82
ystdex::throw_error
void throw_error(std::error_code ec, _tParams &&...args)
抛出错误： std::system_error 或允许相同构造函数参数的异常。
Definition: ystdex/exception.h:206
YSLib::IO::UniqueLockedOutputFileStream
独占锁定的文件输出流。
Definition: File.h:110
IO
ystdex
特性测试宏。
Definition: ydef.h:822
YSLib::IO::UniqueLockedOutputFileStream::UniqueLockedOutputFileStream
UniqueLockedOutputFileStream(int)
YSLib::IO::SharedInputMappedFileStream
共享锁定的文件映射输入流。
Definition: File.h:94
std
Definition: memory.hpp:1183
platform::pmode
YF_API int mode_t pmode
Definition: FileIO.h:542
ystdex::single_thread::lock
void lock(_tLock1 &&, _tLock2 &&, _tLocks &&...)
Definition: pseudo_mutex.h:990
ystdex::threading::lock_guard
Definition: pseudo_mutex.h:222
platform::MappedFile
只读内存映射文件。
Definition: MemoryMapping.h:111
YSLib::path
YF_API const char * path
Definition: Initialization.h:77
YSLib::IO::OpenFile
UniqueFile OpenFile(const char *filename, int omode, mode_t pmode)
Definition: File.cpp:38
YSLib::IO::ImplDeDtor
ImplDeDtor(SharedInputMappedFileStream) UniqueLockedOutputFileStream
Definition: File.cpp:54
ystdex::details::get
get())
Definition: cast.hpp:102