diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-12-16 08:17:28 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-12-16 08:27:35 +0300 |
commit | 8dbd406ea0f495b3d404a7433a32b4781953e55a (patch) | |
tree | c8056b188efa299986b7d936e0b578e9f1f43232 /source/blender/blenlib/BLI_path_util.h | |
parent | 15c36170092d26b7d6106924270b6e590627fcb6 (diff) |
WM: various changes to file writing behavior
Saving with only a filename (from Python) wasn't being prevented,
while it would successfully write the file to the working-directory,
path remapping and setting relative paths wouldn't work afterwards
as `Main.filepath` would have no directory component.
Disallow this since it's a corner case which only ever occurs
when path names without any directories are used from Python,
the overhead of expanding the working-directory for all data saving
operations isn't worthwhile.
The following changes have been made:
- bpy.ops.wm.save_mainfile() without a filepath argument
fails & reports and error when the file hasn't been saved.
Previously it would write to "untitled.blend" and set the
`G.main->filepath` to this as well.
- bpy.ops.wm.save_mainfile(filepath="untitled.blend")
fails & reports and error as the filename has no directory component.
- `BLI_path_is_abs_from_cwd` was added to check if the path would
attempt to expand to the CWD.
Diffstat (limited to 'source/blender/blenlib/BLI_path_util.h')
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 9e2970f6013..3cffecae187 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -324,8 +324,14 @@ void BLI_path_frame_strip(char *path, char *ext) ATTR_NONNULL(); */ bool BLI_path_frame_check_chars(const char *path) ATTR_NONNULL(); /** + * Checks for a relative path (ignoring Blender's "//") prefix + * (unlike `!BLI_path_is_rel(path)`). + * When false, #BLI_path_abs_from_cwd would expand the absolute path. + */ +bool BLI_path_is_abs_from_cwd(const char *path) ATTR_NONNULL(); +/** * Checks for relative path, expanding them relative to the current working directory. - * Returns true if the expansion was performed. + * \returns true if the expansion was performed. * * \note Should only be called with command line paths. * This is _not_ something Blender's internal paths support, instead they use the "//" prefix. |