2019-08-01 02:07:26 -03:00
|
|
|
/*
|
|
|
|
This program 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.
|
|
|
|
|
|
|
|
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-05-14 22:44:22 -03:00
|
|
|
#include "AP_Filesystem_config.h"
|
|
|
|
|
|
|
|
#if AP_FILESYSTEM_POSIX_ENABLED
|
|
|
|
|
2019-08-01 02:07:26 -03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
2020-03-11 03:48:09 -03:00
|
|
|
#include "AP_Filesystem_backend.h"
|
|
|
|
|
|
|
|
class AP_Filesystem_Posix : public AP_Filesystem_Backend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// functions that closely match the equivalent posix calls
|
2022-03-14 11:33:32 -03:00
|
|
|
int open(const char *fname, int flags, bool allow_absolute_paths = false) override;
|
2020-03-11 03:48:09 -03:00
|
|
|
int close(int fd) override;
|
2020-03-29 22:53:29 -03:00
|
|
|
int32_t read(int fd, void *buf, uint32_t count) override;
|
2020-03-30 01:14:35 -03:00
|
|
|
int32_t write(int fd, const void *buf, uint32_t count) override;
|
2020-03-11 03:48:09 -03:00
|
|
|
int fsync(int fd) override;
|
2020-03-29 22:53:29 -03:00
|
|
|
int32_t lseek(int fd, int32_t offset, int whence) override;
|
2020-03-11 03:48:09 -03:00
|
|
|
int stat(const char *pathname, struct stat *stbuf) override;
|
|
|
|
int unlink(const char *pathname) override;
|
|
|
|
int mkdir(const char *pathname) override;
|
|
|
|
void *opendir(const char *pathname) override;
|
|
|
|
struct dirent *readdir(void *dirp) override;
|
|
|
|
int closedir(void *dirp) override;
|
2023-02-21 17:23:28 -04:00
|
|
|
int rename(const char *oldpath, const char *newpath) override;
|
2020-03-11 03:48:09 -03:00
|
|
|
|
|
|
|
// return free disk space in bytes, -1 on error
|
|
|
|
int64_t disk_free(const char *path) override;
|
|
|
|
|
|
|
|
// return total disk space in bytes, -1 on error
|
|
|
|
int64_t disk_space(const char *path) override;
|
|
|
|
|
|
|
|
// set modification time on a file
|
2020-03-29 22:53:29 -03:00
|
|
|
bool set_mtime(const char *filename, const uint32_t mtime_sec) override;
|
2020-03-11 03:48:09 -03:00
|
|
|
};
|
|
|
|
|
2023-05-14 22:44:22 -03:00
|
|
|
#endif // AP_FILESYSTEM_POSIX_ENABLED
|