add error code for file not found. return error code from io::Load, warn and return from io::Store (both without triggering assertions).
remove out of date comment in io.cpp fixes #811 This was SVN commit r9368.
This commit is contained in:
parent
9a125ac5a1
commit
635c2a12e2
@ -32,6 +32,7 @@
|
||||
|
||||
|
||||
ERROR_ASSOCIATE(ERR::FILE_ACCESS, L"Insufficient access rights to open file", EACCES);
|
||||
ERROR_ASSOCIATE(ERR::FILE_NOT_FOUND, L"No such file or directory", ENOENT);
|
||||
|
||||
|
||||
LibError FileOpen(const OsPath& pathname, int opcode, int& fd)
|
||||
|
@ -33,6 +33,7 @@
|
||||
namespace ERR
|
||||
{
|
||||
const LibError FILE_ACCESS = -110300;
|
||||
const LibError FILE_NOT_FOUND = -110301;
|
||||
}
|
||||
|
||||
LIB_API LibError FileOpen(const OsPath& pathname, int opcode, int& fd);
|
||||
|
@ -29,43 +29,6 @@ ERROR_ASSOCIATE(ERR::IO, L"Error during IO", EIO);
|
||||
|
||||
namespace io {
|
||||
|
||||
// the Windows aio implementation requires buffer and offset to be
|
||||
// sector-aligned.
|
||||
//
|
||||
// if the user specifies an unaligned buffer, there's not much we can
|
||||
// do - we can't assume the buffer contains padding. therefore,
|
||||
// callers should let us allocate the buffer if possible.
|
||||
//
|
||||
// if ofs misalign = buffer, only the first and last blocks will need
|
||||
// to be copied by aio, since we read up to the next block boundary.
|
||||
// otherwise, everything will have to be copied; at least we split
|
||||
// the read into blocks, so aio's buffer won't have to cover the
|
||||
// whole file.
|
||||
|
||||
// we don't do any caching or alignment here - this is just a thin
|
||||
// AIO wrapper. rationale:
|
||||
// - aligning the transfer isn't possible here since we have no control
|
||||
// over the buffer, i.e. we cannot read more data than requested.
|
||||
// instead, this is done in manager.
|
||||
// - transfer sizes here are arbitrary (i.e. not block-aligned);
|
||||
// that means the cache would have to handle this or also split them up
|
||||
// into blocks, which would duplicate the above mentioned work.
|
||||
// - if caching here, we'd also have to handle "forwarding" (i.e.
|
||||
// desired block has been issued but isn't yet complete). again, it
|
||||
// is easier to let the synchronous manager handle this.
|
||||
// - finally, manager knows more about whether the block should be cached
|
||||
// (e.g. whether another block request will follow), but we don't
|
||||
// currently make use of this.
|
||||
//
|
||||
// disadvantages:
|
||||
// - streamed data will always be read from disk. that's not a problem,
|
||||
// because such data (e.g. music, long speech) is unlikely to be used
|
||||
// again soon.
|
||||
// - prefetching (issuing the next few blocks from archive/file during
|
||||
// idle time to satisfy potential future IOs) requires extra buffers;
|
||||
// this is a bit more complicated than just using the cache as storage.
|
||||
|
||||
|
||||
UniqueRange Allocate(size_t size, size_t alignment)
|
||||
{
|
||||
ENSURE(is_pow2(alignment));
|
||||
@ -78,6 +41,10 @@ UniqueRange Allocate(size_t size, size_t alignment)
|
||||
}
|
||||
|
||||
|
||||
// this is just a thin wrapper on top of lowio and POSIX aio.
|
||||
// note that the Windows aio implementation requires buffers, sizes and
|
||||
// offsets to be sector-aligned.
|
||||
|
||||
LibError Issue(aiocb& cb, size_t queueDepth)
|
||||
{
|
||||
#if CONFIG2_FILE_ENABLE_AIO
|
||||
|
@ -280,7 +280,8 @@ static inline LibError Run(const Operation& op, const Parameters& p = Parameters
|
||||
template<class CompletedHook, class IssueHook>
|
||||
static inline LibError Store(const OsPath& pathname, const void* data, size_t size, const Parameters& p = Parameters(), const CompletedHook& completedHook = CompletedHook(), const IssueHook& issueHook = IssueHook())
|
||||
{
|
||||
File file(pathname, LIO_WRITE);
|
||||
File file;
|
||||
CHECK_ERR(file.Open(pathname, LIO_WRITE));
|
||||
io::Operation op(file, (void*)data, size);
|
||||
|
||||
#if OS_WIN && CONFIG2_FILE_ENABLE_AIO
|
||||
@ -315,7 +316,8 @@ static inline LibError Store(const OsPath& pathname, const void* data, size_t si
|
||||
template<class CompletedHook, class IssueHook>
|
||||
static inline LibError Load(const OsPath& pathname, void* buf, size_t size, const Parameters& p = Parameters(), const CompletedHook& completedHook = CompletedHook(), const IssueHook& issueHook = IssueHook())
|
||||
{
|
||||
File file(pathname, LIO_READ);
|
||||
File file;
|
||||
RETURN_ERR(file.Open(pathname, LIO_READ));
|
||||
io::Operation op(file, buf, size);
|
||||
return io::Run(op, p, completedHook, issueHook);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user