2016-08-06 06:59:41 +00:00
|
|
|
/*
|
2017-10-13 10:42:36 +00:00
|
|
|
VitaShell
|
2017-12-30 10:43:37 +00:00
|
|
|
Copyright (C) 2015-2018, TheFloW
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2017-10-13 10:42:36 +00: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.
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2017-10-13 10:42:36 +00:00
|
|
|
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.
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2017-10-13 10:42:36 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-08-06 06:59:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __FILE_H__
|
|
|
|
#define __FILE_H__
|
|
|
|
|
2016-11-05 23:29:27 +00:00
|
|
|
#define SCE_ERROR_ERRNO_EEXIST 0x80010011
|
|
|
|
#define SCE_ERROR_ERRNO_ENODEV 0x80010013
|
|
|
|
|
2016-08-06 06:59:41 +00:00
|
|
|
#define MAX_PATH_LENGTH 1024
|
|
|
|
#define MAX_NAME_LENGTH 256
|
|
|
|
#define MAX_SHORT_NAME_LENGTH 64
|
2017-09-16 11:40:19 +00:00
|
|
|
#define MAX_MOUNT_POINT_LENGTH 16
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2016-10-25 08:43:10 +00:00
|
|
|
#define DIRECTORY_SIZE (4 * 1024)
|
2018-01-25 21:22:07 +00:00
|
|
|
#define TRANSFER_SIZE (128 * 1024)
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2018-09-13 10:00:30 +00:00
|
|
|
#define SYMLINK_HEADER_SIZE 4
|
|
|
|
#define SYMLINK_MAX_SIZE (SYMLINK_HEADER_SIZE + MAX_PATH_LENGTH)
|
|
|
|
#define SYMLINK_EXT "lnk"
|
|
|
|
extern const char symlink_header_bytes[SYMLINK_HEADER_SIZE];
|
|
|
|
|
|
|
|
|
2016-08-06 06:59:41 +00:00
|
|
|
enum FileTypes {
|
2017-10-13 10:42:36 +00:00
|
|
|
FILE_TYPE_UNKNOWN,
|
2017-12-31 00:47:19 +00:00
|
|
|
FILE_TYPE_ARCHIVE,
|
2017-10-13 10:42:36 +00:00
|
|
|
FILE_TYPE_BMP,
|
|
|
|
FILE_TYPE_INI,
|
|
|
|
FILE_TYPE_JPEG,
|
|
|
|
FILE_TYPE_MP3,
|
|
|
|
FILE_TYPE_MP4,
|
|
|
|
FILE_TYPE_OGG,
|
|
|
|
FILE_TYPE_PNG,
|
2017-12-31 00:47:19 +00:00
|
|
|
FILE_TYPE_PSP2DMP,
|
2017-10-13 10:42:36 +00:00
|
|
|
FILE_TYPE_SFO,
|
|
|
|
FILE_TYPE_TXT,
|
|
|
|
FILE_TYPE_VPK,
|
|
|
|
FILE_TYPE_XML,
|
2016-08-06 06:59:41 +00:00
|
|
|
};
|
|
|
|
|
2016-09-10 12:35:15 +00:00
|
|
|
enum FileSortFlags {
|
2017-10-13 10:42:36 +00:00
|
|
|
SORT_NONE,
|
|
|
|
SORT_BY_NAME,
|
|
|
|
SORT_BY_SIZE,
|
|
|
|
SORT_BY_DATE,
|
2016-08-06 06:59:41 +00:00
|
|
|
};
|
|
|
|
|
2016-09-10 12:35:15 +00:00
|
|
|
enum FileMoveFlags {
|
2017-10-13 10:42:36 +00:00
|
|
|
MOVE_INTEGRATE = 0x1, // Integrate directories
|
2017-12-30 22:08:04 +00:00
|
|
|
MOVE_REPLACE = 0x2, // Replace files
|
2016-09-06 19:19:21 +00:00
|
|
|
};
|
|
|
|
|
2018-09-13 10:00:30 +00:00
|
|
|
typedef struct {
|
|
|
|
int to_file; // 1: to file, 0: to directory
|
|
|
|
char *target_path;
|
|
|
|
int target_path_length;
|
|
|
|
} Symlink;
|
|
|
|
|
2016-09-10 12:35:15 +00:00
|
|
|
typedef struct {
|
2017-10-13 10:42:36 +00:00
|
|
|
uint64_t *value;
|
|
|
|
uint64_t max;
|
|
|
|
void (* SetProgress)(uint64_t value, uint64_t max);
|
|
|
|
int (* cancelHandler)();
|
2016-09-10 12:35:15 +00:00
|
|
|
} FileProcessParam;
|
|
|
|
|
2016-08-06 06:59:41 +00:00
|
|
|
typedef struct FileListEntry {
|
2017-10-13 10:42:36 +00:00
|
|
|
struct FileListEntry *next;
|
|
|
|
struct FileListEntry *previous;
|
2018-01-03 21:37:11 +00:00
|
|
|
char *name;
|
2017-10-13 10:42:36 +00:00
|
|
|
int name_length;
|
|
|
|
int is_folder;
|
|
|
|
int type;
|
2018-09-13 10:00:30 +00:00
|
|
|
int is_symlink;
|
|
|
|
Symlink *symlink;
|
2017-10-13 10:42:36 +00:00
|
|
|
SceOff size;
|
|
|
|
SceOff size2;
|
|
|
|
SceDateTime ctime;
|
|
|
|
SceDateTime mtime;
|
|
|
|
SceDateTime atime;
|
2016-08-06 06:59:41 +00:00
|
|
|
} FileListEntry;
|
|
|
|
|
|
|
|
typedef struct {
|
2017-10-13 10:42:36 +00:00
|
|
|
FileListEntry *head;
|
|
|
|
FileListEntry *tail;
|
|
|
|
int length;
|
|
|
|
char path[MAX_PATH_LENGTH];
|
|
|
|
int files;
|
|
|
|
int folders;
|
2018-01-25 15:48:51 +00:00
|
|
|
int is_in_archive;
|
2016-08-06 06:59:41 +00:00
|
|
|
} FileList;
|
|
|
|
|
2017-02-12 15:27:43 +00:00
|
|
|
int allocateReadFile(const char *file, void **buffer);
|
|
|
|
int ReadFile(const char *file, void *buf, int size);
|
|
|
|
int WriteFile(const char *file, const void *buf, int size);
|
2017-09-16 11:40:19 +00:00
|
|
|
|
2017-03-05 14:27:16 +00:00
|
|
|
int checkFileExist(const char *file);
|
2017-09-16 11:40:19 +00:00
|
|
|
int checkFolderExist(const char *folder);
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2018-09-13 10:00:30 +00:00
|
|
|
|
|
|
|
char * getBaseDirectory(const char *path);
|
|
|
|
char * getFilename(const char *path);
|
|
|
|
|
2017-02-12 15:27:43 +00:00
|
|
|
int getFileSize(const char *file);
|
|
|
|
int getFileSha1(const char *file, uint8_t *pSha1Out, FileProcessParam *param);
|
|
|
|
int getPathInfo(const char *path, uint64_t *size, uint32_t *folders, uint32_t *files, int (* handler)(const char *path));
|
|
|
|
int removePath(const char *path, FileProcessParam *param);
|
|
|
|
int copyFile(const char *src_path, const char *dst_path, FileProcessParam *param);
|
|
|
|
int copyPath(const char *src_path, const char *dst_path, FileProcessParam *param);
|
|
|
|
int movePath(const char *src_path, const char *dst_path, int flags, FileProcessParam *param);
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2017-02-12 15:27:43 +00:00
|
|
|
int getFileType(const char *file);
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2016-11-01 15:34:15 +00:00
|
|
|
int getNumberOfDevices();
|
|
|
|
char **getDevices();
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2018-01-02 19:50:41 +00:00
|
|
|
FileListEntry *fileListCopyEntry(FileListEntry *src);
|
2017-02-12 15:27:43 +00:00
|
|
|
FileListEntry *fileListFindEntry(FileList *list, const char *name);
|
2016-08-06 06:59:41 +00:00
|
|
|
FileListEntry *fileListGetNthEntry(FileList *list, int n);
|
2017-02-12 15:27:43 +00:00
|
|
|
int fileListGetNumberByName(FileList *list, const char *name);
|
2016-09-04 13:30:39 +00:00
|
|
|
|
2016-08-06 06:59:41 +00:00
|
|
|
void fileListAddEntry(FileList *list, FileListEntry *entry, int sort);
|
|
|
|
int fileListRemoveEntry(FileList *list, FileListEntry *entry);
|
2017-02-12 15:27:43 +00:00
|
|
|
int fileListRemoveEntryByName(FileList *list, const char *name);
|
2016-09-04 13:30:39 +00:00
|
|
|
|
2016-08-06 06:59:41 +00:00
|
|
|
void fileListEmpty(FileList *list);
|
2016-09-04 13:30:39 +00:00
|
|
|
|
2017-02-12 15:27:43 +00:00
|
|
|
int fileListGetEntries(FileList *list, const char *path, int sort);
|
2016-08-06 06:59:41 +00:00
|
|
|
|
2018-09-13 10:00:30 +00:00
|
|
|
int resolveSimLink(Symlink* symlink, const char *target);
|
|
|
|
int createSymLink(const char *source_location, const char *target);
|
|
|
|
|
2016-08-08 21:31:41 +00:00
|
|
|
#endif
|