Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_Filesystem/AP_Filesystem_posix.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/1415#pragma once1617#include "AP_Filesystem_config.h"1819#if AP_FILESYSTEM_POSIX_ENABLED2021#include <sys/types.h>22#include <sys/stat.h>23#include <fcntl.h>24#include <stddef.h>25#include <stdio.h>26#include <dirent.h>27#include <unistd.h>28#include <errno.h>29#include "AP_Filesystem_backend.h"3031#ifndef AP_FILESYSTEM_POSIX_HAVE_UTIME32#define AP_FILESYSTEM_POSIX_HAVE_UTIME 133#endif3435#ifndef AP_FILESYSTEM_POSIX_HAVE_FSYNC36#define AP_FILESYSTEM_POSIX_HAVE_FSYNC 137#endif3839#ifndef AP_FILESYSTEM_POSIX_HAVE_STATFS40#define AP_FILESYSTEM_POSIX_HAVE_STATFS 141#endif4243#ifndef O_CLOEXEC44#define O_CLOEXEC 045#endif4647class AP_Filesystem_Posix : public AP_Filesystem_Backend48{49public:50// functions that closely match the equivalent posix calls51int open(const char *fname, int flags, bool allow_absolute_paths = false) override;52int close(int fd) override;53int32_t read(int fd, void *buf, uint32_t count) override;54int32_t write(int fd, const void *buf, uint32_t count) override;55int fsync(int fd) override;56int32_t lseek(int fd, int32_t offset, int whence) override;57int stat(const char *pathname, struct stat *stbuf) override;58int unlink(const char *pathname) override;59int mkdir(const char *pathname) override;60void *opendir(const char *pathname) override;61struct dirent *readdir(void *dirp) override;62int closedir(void *dirp) override;63int rename(const char *oldpath, const char *newpath) override;6465// return free disk space in bytes, -1 on error66int64_t disk_free(const char *path) override;6768// return total disk space in bytes, -1 on error69int64_t disk_space(const char *path) override;7071// set modification time on a file72bool set_mtime(const char *filename, const uint32_t mtime_sec) override;73};7475#endif // AP_FILESYSTEM_POSIX_ENABLED767778