sortix-mirror/sortix/filesystem.h

78 lines
2.0 KiB
C
Raw Normal View History

2011-08-05 12:25:00 +00: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
Allows access to stored sequences of bytes in an orderly fashion.
2011-08-05 12:25:00 +00:00
******************************************************************************/
#ifndef SORTIX_FILESYSTEM_H
#define SORTIX_FILESYSTEM_H
#include "device.h"
2011-11-18 16:49:31 +00:00
#include "stream.h"
#include "fcntl.h"
2011-08-05 12:25:00 +00:00
namespace Sortix
{
class DevFileSystem : public Device
{
public:
virtual Device* Open(const char* path, int flags, mode_t mode) = 0;
2011-11-21 17:49:55 +00:00
virtual bool Unlink(const char* path) = 0;
2011-08-05 12:25:00 +00:00
2011-11-18 16:49:31 +00:00
public:
virtual bool IsType(unsigned type) const { return type == Device::FILESYSTEM; }
2011-11-18 16:49:31 +00: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(uint8_t* dest, size_t count);
virtual ssize_t Write(const uint8_t* src, size_t count);
2011-11-18 16:49:31 +00:00
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 12:25:00 +00:00
};
namespace FileSystem
{
void Init();
Device* Open(const char* path, int flags, mode_t mode);
2011-11-21 17:49:55 +00:00
bool Unlink(const char* path);
2011-08-05 12:25:00 +00:00
}
}
#endif