From fade37ff07ab3b62844068a1a5d60dd74ea787f6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Jun 2020 15:41:07 +1000 Subject: Writefile: move file flags to BlendFileWriteParams This removes G_FILE_HISTORY, G_FILE_SAVE_COPY & G_FILE_USERPREFS. Using file-flags made logic harder to follow since it's not so clear which flags are expected to be in G.fileflags & which are meant to be set and passed as arguments, these are shared between read & write functions too. Add BlendFileWriteParams so options which don't need to be stored aren't mixed up with flags that are stored for reuse. --- source/blender/blenloader/BLO_writefile.h | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'source/blender/blenloader/BLO_writefile.h') diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h index 18783474392..32cb6633c12 100644 --- a/source/blender/blenloader/BLO_writefile.h +++ b/source/blender/blenloader/BLO_writefile.h @@ -35,25 +35,30 @@ struct ReportList; */ typedef enum eBLO_WritePathRemap { /** No path manipulation. */ - BLO_WRITE_PATH_REMAP_NONE = 1, + BLO_WRITE_PATH_REMAP_NONE = 0, /** Remap existing relative paths (default). */ - BLO_WRITE_PATH_REMAP_RELATIVE = 2, + BLO_WRITE_PATH_REMAP_RELATIVE = 1, /** Remap paths making all paths relative to the new location. */ - BLO_WRITE_PATH_REMAP_RELATIVE_ALL = 3, + BLO_WRITE_PATH_REMAP_RELATIVE_ALL = 2, /** Make all paths absolute. */ - BLO_WRITE_PATH_REMAP_ABSOLUTE = 4, + BLO_WRITE_PATH_REMAP_ABSOLUTE = 3, } eBLO_WritePathRemap; -extern bool BLO_write_file_ex(struct Main *mainvar, - const char *filepath, - const int write_flags, - struct ReportList *reports, - /* Extra arguments. */ - eBLO_WritePathRemap remap_mode, - const struct BlendThumbnail *thumb); +/** Similar to #BlendFileReadParams. */ +struct BlendFileWriteParams { + eBLO_WritePathRemap remap_mode; + /** Save `.blend1`, `.blend2`... etc. */ + uint use_save_versions : 1; + /** On write, restore paths after editing them (see #BLO_WRITE_PATH_REMAP_RELATIVE). */ + uint use_save_as_copy : 1; + uint use_userdef : 1; + const struct BlendThumbnail *thumb; +}; + extern bool BLO_write_file(struct Main *mainvar, const char *filepath, const int write_flags, + const struct BlendFileWriteParams *params, struct ReportList *reports); extern bool BLO_write_file_mem(struct Main *mainvar, -- cgit v1.2.3