first commit

This commit is contained in:
2026-06-22 11:49:35 +02:00
commit d805f2ba86
619 changed files with 126873 additions and 0 deletions

View File

@ -0,0 +1,66 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NIOALIAS__
#define __NIOALIAS__
#include <stdio.h>
#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 <Base> iofs;
public:
//----------------------------------------------------------------------
Map <String, String> alias_map;
String ResolveAlias(const char *path) const
{
Pair <String, String> *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__