2011-08-05 08:25:00 -04:00
|
|
|
/******************************************************************************
|
|
|
|
|
|
|
|
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011.
|
|
|
|
|
|
|
|
This file is part of Sortix.
|
|
|
|
|
|
|
|
Sortix is free software: you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with Sortix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
filesystem.h
|
2011-11-17 17:31:41 -05:00
|
|
|
Allows access to stored sequences of bytes in an orderly fashion.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef SORTIX_FILESYSTEM_H
|
|
|
|
#define SORTIX_FILESYSTEM_H
|
|
|
|
|
|
|
|
#include "device.h"
|
2011-11-18 11:49:31 -05:00
|
|
|
#include "stream.h"
|
2012-02-23 07:15:40 -05:00
|
|
|
#include "fcntl.h"
|
2011-08-05 08:25:00 -04:00
|
|
|
|
|
|
|
namespace Sortix
|
|
|
|
{
|
|
|
|
class DevFileSystem : public Device
|
|
|
|
{
|
|
|
|
public:
|
2011-11-17 17:31:41 -05:00
|
|
|
virtual Device* Open(const char* path, int flags, mode_t mode) = 0;
|
2011-11-21 12:49:55 -05:00
|
|
|
virtual bool Unlink(const char* path) = 0;
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2011-11-18 11:49:31 -05:00
|
|
|
public:
|
2012-01-17 19:11:17 -05:00
|
|
|
virtual bool IsType(unsigned type) const { return type == Device::FILESYSTEM; }
|
2011-11-18 11:49:31 -05:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class DevFileWrapper : public DevBuffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DevFileWrapper(DevBuffer* buffer, int flags);
|
|
|
|
virtual ~DevFileWrapper();
|
|
|
|
|
|
|
|
private:
|
|
|
|
DevBuffer* buffer;
|
|
|
|
int flags;
|
|
|
|
uintmax_t offset;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ssize_t Read(byte* dest, size_t count);
|
|
|
|
virtual ssize_t Write(const byte* src, size_t count);
|
|
|
|
virtual bool IsReadable();
|
|
|
|
virtual bool IsWritable();
|
|
|
|
virtual size_t BlockSize();
|
|
|
|
virtual uintmax_t Size();
|
|
|
|
virtual uintmax_t Position();
|
|
|
|
virtual bool Seek(uintmax_t position);
|
|
|
|
virtual bool Resize(uintmax_t size);
|
2011-08-05 08:25:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace FileSystem
|
|
|
|
{
|
2011-11-17 17:31:41 -05:00
|
|
|
void Init();
|
|
|
|
Device* Open(const char* path, int flags, mode_t mode);
|
2011-11-21 12:49:55 -05:00
|
|
|
bool Unlink(const char* path);
|
2011-08-05 08:25:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|