[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13936] trunk/blender/source/blender/src: made it possible to type in ~ at the start of the filename, ~/ Desktop for instance.
Campbell Barton
ideasman42 at gmail.com
Sun Mar 2 01:26:13 CET 2008
Revision: 13936
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13936
Author: campbellbarton
Date: 2008-03-02 01:26:13 +0100 (Sun, 02 Mar 2008)
Log Message:
-----------
made it possible to type in ~ at the start of the filename, ~/Desktop for instance.
Enabled for win32 and in the image browser.
Modified Paths:
--------------
trunk/blender/source/blender/src/editimasel.c
trunk/blender/source/blender/src/filesel.c
Modified: trunk/blender/source/blender/src/editimasel.c
===================================================================
--- trunk/blender/source/blender/src/editimasel.c 2008-03-01 19:46:50 UTC (rev 13935)
+++ trunk/blender/source/blender/src/editimasel.c 2008-03-02 00:26:13 UTC (rev 13936)
@@ -594,7 +594,21 @@
}
}
else if(event== B_FS_DIRNAME) {
- /* reuse the butname variable */
+
+ /* convienence shortcut '~' -> $HOME
+ * If the first char is ~ then this is invalid on all OS's so its safe to replace with home */
+ if ( simasel->dir[0] == '~' ) {
+ if (simasel->dir[1] == '\0') {
+ BLI_strncpy(simasel->dir, BLI_gethome(), sizeof(simasel->dir) );
+ } else {
+ /* replace ~ with home */
+ char tmpstr[FILE_MAX];
+ BLI_join_dirfile(tmpstr, BLI_gethome(), simasel->dir+1);
+ BLI_strncpy(simasel->dir, tmpstr, sizeof(simasel->dir));
+ }
+ }
+
+ /* reuse the butname vsariable */
BLI_cleanup_dir(G.sce, simasel->dir);
BLI_make_file_string(G.sce, butname, simasel->dir, "");
Modified: trunk/blender/source/blender/src/filesel.c
===================================================================
--- trunk/blender/source/blender/src/filesel.c 2008-03-01 19:46:50 UTC (rev 13935)
+++ trunk/blender/source/blender/src/filesel.c 2008-03-02 00:26:13 UTC (rev 13936)
@@ -1529,12 +1529,19 @@
else if(event== B_FS_DIRNAME) {
/* reuse the butname variable */
-#ifndef WIN32
- /* convienence shortcut '~' -> $HOME */
- if ( sfile->dir[0] == '~' && sfile->dir[1] == '\0' ) {
- BLI_strncpy(sfile->dir, BLI_gethome(), sizeof(sfile->dir) );
+ /* convienence shortcut '~' -> $HOME
+ * If the first char is ~ then this is invalid on all OS's so its safe to replace with home */
+ if ( sfile->dir[0] == '~' ) {
+ if (sfile->dir[1] == '\0') {
+ BLI_strncpy(sfile->dir, BLI_gethome(), sizeof(sfile->dir) );
+ } else {
+ /* replace ~ with home */
+ char tmpstr[FILE_MAX];
+ BLI_join_dirfile(tmpstr, BLI_gethome(), sfile->dir+1);
+ BLI_strncpy(sfile->dir, tmpstr, sizeof(sfile->dir));
+ }
}
-#endif
+
BLI_cleanup_dir(G.sce, sfile->dir);
BLI_make_file_string(G.sce, butname, sfile->dir, "");
More information about the Bf-blender-cvs
mailing list