/* ----------------------------------------------------------------------------- GSFramework Copyright 2001-2013 Emmanuel Julien. All Rights Reserved. ----------------------------------------------------------------------------- */ #ifndef __NIOALIAS__ #define __NIOALIAS__ #include #include "nstring/nstring.h" #include "container/nmap.h" namespace GS { namespace IO { class Handle; /*! @short Alias proxy I/O. A simple proxy I/O to provide filename aliasing to another I/O system. @author Emmanuel Julien (ejulien@nworks.fr) */ class Alias : public Base { SharedPtr iofs; public: //---------------------------------------------------------------------- Map alias_map; String ResolveAlias(const char *path) const { Pair *alias = alias_map.Get(path); return alias ? alias->value : path; } //---------------------------------------------------------------------- virtual Handle *Open(const char *path, Mode mode = IORead) { return iofs->Open(ResolveAlias(path), mode); } virtual void Close(Handle *h) { iofs->Close(h); } virtual bool Delete(const char *path) { return iofs->Delete(ResolveAlias(path)); } virtual size_t Tell(Handle *h) { return iofs->Tell(h); } virtual size_t Seek(Handle *h, ptrdiff_t offset, SeekRef seek_ref = SeekCurrent) { return iofs->Seek(h, offset, seek_ref); } virtual size_t Read(Handle *h, void *p, size_t size) { return iofs->Read(h, p, size); } virtual size_t Write(Handle *h, const void *p, size_t size) { return iofs->Write(h, p, size); } Alias(Base *io) : iofs(io) {} }; } // IO } // GS #endif // __NIOALIAS__