diff options
author | Julian Eisel <julian@blender.org> | 2020-03-26 23:03:42 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-03-26 23:18:45 +0300 |
commit | c94b6209861ca7cc3985b53474feed7d94c0221a (patch) | |
tree | 752054f0dca1338cda5cf8ad4f6d18573fcca3b9 /source/blender/blenlib/BLI_fileops.h | |
parent | 357ed79cb93f9d655501a828c6cddd68282de62d (diff) | |
parent | afb1a64ccb81b7ed792f64151986f40f53af8da5 (diff) |
Merge branch 'master' into wm-drag-drop-rewrite
Diffstat (limited to 'source/blender/blenlib/BLI_fileops.h')
-rw-r--r-- | source/blender/blenlib/BLI_fileops.h | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index 5c20e57181e..4eb6f184a76 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -25,9 +25,9 @@ #ifndef __BLI_FILEOPS_H__ #define __BLI_FILEOPS_H__ +#include <stdint.h> #include <stdio.h> #include <sys/stat.h> -#include <stdint.h> #ifdef __cplusplus extern "C" { @@ -39,6 +39,7 @@ extern "C" { #include <limits.h> /* for PATH_MAX */ #include "BLI_compiler_attrs.h" +#include "BLI_utildefines.h" #ifndef PATH_MAX # define PATH_MAX 4096 @@ -69,10 +70,37 @@ typedef struct stat BLI_stat_t; int BLI_fstat(int fd, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); int BLI_stat(const char *path, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +int64_t BLI_ftell(FILE *stream) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +int BLI_fseek(FILE *stream, int64_t offset, int whence); +int64_t BLI_lseek(int fd, int64_t offset, int whence); + #ifdef WIN32 int BLI_wstat(const wchar_t *path, BLI_stat_t *buffer); #endif +typedef enum eFileAttributes { + FILE_ATTR_READONLY = 1 << 0, /* Read-only or Immutable. */ + FILE_ATTR_HIDDEN = 1 << 1, /* Hidden or invisible. */ + FILE_ATTR_SYSTEM = 1 << 2, /* Used by the Operating System. */ + FILE_ATTR_ARCHIVE = 1 << 3, /* Marked as archived. */ + FILE_ATTR_COMPRESSED = 1 << 4, /* Compressed. */ + FILE_ATTR_ENCRYPTED = 1 << 5, /* Encrypted. */ + FILE_ATTR_RESTRICTED = 1 << 6, /* Protected by OS. */ + FILE_ATTR_TEMPORARY = 1 << 7, /* Used for temporary storage. */ + FILE_ATTR_SPARSE_FILE = 1 << 8, /* Sparse File. */ + FILE_ATTR_OFFLINE = 1 << 9, /* Data is not immediately available. */ + FILE_ATTR_ALIAS = 1 << 10, /* Mac Alias or Windows Lnk. File-based redirection. */ + FILE_ATTR_REPARSE_POINT = 1 << 11, /* File has associated reparse point. */ + FILE_ATTR_SYMLINK = 1 << 12, /* Reference to another file. */ + FILE_ATTR_JUNCTION_POINT = 1 << 13, /* Folder Symlink. */ + FILE_ATTR_MOUNT_POINT = 1 << 14, /* Volume mounted as a folder. */ + FILE_ATTR_HARDLINK = 1 << 15, /* Duplicated directory entry. */ +} eFileAttributes; + +#define FILE_ATTR_ANY_LINK \ + (FILE_ATTR_ALIAS | FILE_ATTR_REPARSE_POINT | FILE_ATTR_SYMLINK | FILE_ATTR_JUNCTION_POINT | \ + FILE_ATTR_MOUNT_POINT | FILE_ATTR_HARDLINK) + /* Directories */ struct direntry; @@ -83,6 +111,7 @@ bool BLI_dir_create_recursive(const char *dir) ATTR_NONNULL(); double BLI_dir_free_space(const char *dir) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); char *BLI_current_working_dir(char *dir, const size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +eFileAttributes BLI_file_attributes(const char *path); /* Filelist */ @@ -118,13 +147,20 @@ int BLI_access(const char *filename, int mode) ATTR_WARN_UNUSED_RESULT ATTR_NONN bool BLI_file_is_writable(const char *file) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); bool BLI_file_touch(const char *file) ATTR_NONNULL(); +bool BLI_file_alias_target(char *target, const char *filepath); #if 0 /* UNUSED */ int BLI_file_gzip(const char *from, const char *to) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); #endif char *BLI_file_ungzip_to_mem(const char *from_file, int *r_size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); - +size_t BLI_gzip_mem_to_file_at_pos(void *buf, + size_t len, + FILE *file, + size_t gz_stream_offset, + int compression_level) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +size_t BLI_ungzip_file_to_mem_at_pos(void *buf, size_t len, FILE *file, size_t gz_stream_offset) + ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); size_t BLI_file_descriptor_size(int file) ATTR_WARN_UNUSED_RESULT; size_t BLI_file_size(const char *file) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); @@ -134,6 +170,10 @@ bool BLI_file_older(const char *file1, const char *file2) ATTR_WARN_UNUSED_RESUL /* read ascii file as lines, empty list if reading fails */ struct LinkNode *BLI_file_read_as_lines(const char *file) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); void *BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size); +void *BLI_file_read_text_as_mem_with_newline_as_nil(const char *filepath, + bool trim_trailing_space, + size_t pad_bytes, + size_t *r_size); void *BLI_file_read_binary_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size); void BLI_file_free_lines(struct LinkNode *lines); |