[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36736] trunk/blender/source: cleanup only

Campbell Barton ideasman42 at gmail.com
Wed May 18 08:27:32 CEST 2011


Revision: 36736
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36736
Author:   campbellbarton
Date:     2011-05-18 06:27:32 +0000 (Wed, 18 May 2011)
Log Message:
-----------
cleanup only
- rename 'name', 'dir' --> 'filepath' where these actually represent a file path to avoid confusion.
- bugfix for possible (but unlikely) uninitialized string.
- remove commented script append function, now we have a python api for this.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/blender.c
    trunk/blender/source/blender/blenloader/BLO_readfile.h
    trunk/blender/source/blender/blenloader/BLO_writefile.h
    trunk/blender/source/blender/blenloader/intern/readblenentry.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/blenloader/intern/readfile.h
    trunk/blender/source/blender/blenloader/intern/writefile.c
    trunk/blender/source/blender/windowmanager/WM_api.h
    trunk/blender/source/blender/windowmanager/intern/wm_files.c
    trunk/blender/source/blender/windowmanager/wm.h
    trunk/blender/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp

Modified: trunk/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/blender.c	2011-05-18 05:21:44 UTC (rev 36735)
+++ trunk/blender/source/blender/blenkernel/intern/blender.c	2011-05-18 06:27:32 UTC (rev 36736)
@@ -191,7 +191,7 @@
 /* note, this is called on Undo so any slow conversion functions here
  * should be avoided or check (mode!='u') */
 
-static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename) 
+static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath)
 {
 	bScreen *curscreen= NULL;
 	Scene *curscene= NULL;
@@ -295,18 +295,18 @@
 	if(recover && bfd->filename[0] && G.relbase_valid) {
 		/* in case of autosave or quit.blend, use original filename instead
 		 * use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */
-		filename= bfd->filename;
+		filepath= bfd->filename;
 	}
 #if 0
 	else if (!G.relbase_valid) {
 		/* otherwise, use an empty string as filename, rather than <memory2> */
-		filename="";
+		filepath="";
 	}
 #endif
 	
 	/* these are the same at times, should never copy to the same location */
-	if(G.main->name != filename)
-		BLI_strncpy(G.main->name, filename, FILE_MAX);
+	if(G.main->name != filepath)
+		BLI_strncpy(G.main->name, filepath, FILE_MAX);
 
 	/* baseflags, groups, make depsgraph, etc */
 	set_scene_bg(G.main, CTX_data_scene(C));
@@ -353,15 +353,15 @@
 	BLI_freelistN(&U.addons);
 }
 
-int BKE_read_file(bContext *C, const char *dir, ReportList *reports) 
+int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
 {
 	BlendFileData *bfd;
 	int retval= BKE_READ_FILE_OK;
 
-	if(strstr(dir, BLENDER_STARTUP_FILE)==NULL) /* dont print user-pref loading */
-		printf("read blend: %s\n", dir);
+	if(strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* dont print user-pref loading */
+		printf("read blend: %s\n", filepath);
 
-	bfd= BLO_read_from_file(dir, reports);
+	bfd= BLO_read_from_file(filepath, reports);
 	if (bfd) {
 		if(bfd->user) retval= BKE_READ_FILE_OK_USERPREFS;
 		
@@ -372,10 +372,10 @@
 			retval= BKE_READ_FILE_FAIL;
 		}
 		else
-			setup_app_data(C, bfd, dir); // frees BFD
+			setup_app_data(C, bfd, filepath); // frees BFD
 	} 
 	else
-		BKE_reports_prependf(reports, "Loading %s failed: ", dir);
+		BKE_reports_prependf(reports, "Loading %s failed: ", filepath);
 		
 	return (bfd?retval:BKE_READ_FILE_FAIL);
 }
@@ -521,19 +521,19 @@
 	/* disk save version */
 	if(UNDO_DISK) {
 		static int counter= 0;
-		char tstr[FILE_MAXDIR+FILE_MAXFILE];
+		char filepath[FILE_MAXDIR+FILE_MAXFILE];
 		char numstr[32];
 		
-		/* calculate current filename */
+		/* calculate current filepath */
 		counter++;
 		counter= counter % U.undosteps;	
 	
 		BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
-		BLI_make_file_string("/", tstr, btempdir, numstr);
+		BLI_make_file_string("/", filepath, btempdir, numstr);
 	
-		success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL, NULL);
+		success= BLO_write_file(CTX_data_main(C), filepath, G.fileflags, NULL, NULL);
 		
-		BLI_strncpy(curundo->str, tstr, sizeof(curundo->str));
+		BLI_strncpy(curundo->str, filepath, sizeof(curundo->str));
 	}
 	else {
 		MemFile *prevfile=NULL;

Modified: trunk/blender/source/blender/blenloader/BLO_readfile.h
===================================================================
--- trunk/blender/source/blender/blenloader/BLO_readfile.h	2011-05-18 05:21:44 UTC (rev 36735)
+++ trunk/blender/source/blender/blenloader/BLO_readfile.h	2011-05-18 06:27:32 UTC (rev 36736)
@@ -79,12 +79,12 @@
 	 * returns NULL and sets a report in the list if
 	 * it cannot open the file.
 	 * 
-	 * @param file The path of the file to open.
+	 * @param filepath The path of the file to open.
 	 * @param reports If the return value is NULL, errors
 	 * indicating the cause of the failure.
 	 * @return The data of the file.
 	 */
-BlendFileData*	BLO_read_from_file(const char *file, struct ReportList *reports);
+BlendFileData*	BLO_read_from_file(const char *filepath, struct ReportList *reports);
 
 	/**
 	 * Open a blender file from memory. The function
@@ -209,7 +209,7 @@
  */
 int BLO_is_a_library(const char *path, char *dir, char *group);
 
-struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, char *dir);
+struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, const char *filepath);
 
 /**
  * Link/Append a named datablock from an external blend file.
@@ -217,12 +217,12 @@
  * @param C The context, when NULL instancing object in the scene isnt done.
  * @param mainl The main database to link from (not the active one).
  * @param bh The blender file handle.
- * @param name The name of the datablock (without the 2 char ID prefix)
+ * @param idname The name of the datablock (without the 2 char ID prefix)
  * @param idcode The kind of datablock to link.
  * @param flag Options for linking, used for instancing.
  * @return Boolean, 0 when the datablock could not be found.
  */
-int BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *name, int idcode, short flag);
+int BLO_library_append_named_part(const struct bContext *C, struct Main *mainl, BlendHandle** bh, const char *idname, int idcode, short flag);
 void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag);
 
 /* deprecated */

Modified: trunk/blender/source/blender/blenloader/BLO_writefile.h
===================================================================
--- trunk/blender/source/blender/blenloader/BLO_writefile.h	2011-05-18 05:21:44 UTC (rev 36735)
+++ trunk/blender/source/blender/blenloader/BLO_writefile.h	2011-05-18 06:27:32 UTC (rev 36736)
@@ -39,7 +39,7 @@
 struct Main;
 struct ReportList;
 
-extern int BLO_write_file(struct Main *mainvar, char *dir, int write_flags, struct ReportList *reports, int *thumb);
+extern int BLO_write_file(struct Main *mainvar, const char *filepath, int write_flags, struct ReportList *reports, int *thumb);
 extern int BLO_write_file_mem(struct Main *mainvar, struct MemFile *compare, struct MemFile *current, int write_flags);
 extern int BLO_write_runtime(struct Main *mainvar, const char *file, char *exename, struct ReportList *reports);
 

Modified: trunk/blender/source/blender/blenloader/intern/readblenentry.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readblenentry.c	2011-05-18 05:21:44 UTC (rev 36735)
+++ trunk/blender/source/blender/blenloader/intern/readblenentry.c	2011-05-18 06:27:32 UTC (rev 36736)
@@ -251,15 +251,15 @@
 
 	/**********/
 
-BlendFileData *BLO_read_from_file(const char *file, ReportList *reports)
+BlendFileData *BLO_read_from_file(const char *filepath, ReportList *reports)
 {
 	BlendFileData *bfd = NULL;
 	FileData *fd;
 		
-	fd = blo_openblenderfile(file, reports);
+	fd = blo_openblenderfile(filepath, reports);
 	if (fd) {
 		fd->reports= reports;
-		bfd= blo_read_file_internal(fd, file);
+		bfd= blo_read_file_internal(fd, filepath);
 		blo_freefiledata(fd);			
 	}
 

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2011-05-18 05:21:44 UTC (rev 36735)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2011-05-18 06:27:32 UTC (rev 36736)
@@ -487,13 +487,13 @@
 }
 
 
-static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *name, const char *relabase)
+static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *filepath, const char *relabase)
 {
 	Main *m;
 	Library *lib;
 	char name1[FILE_MAXDIR+FILE_MAXFILE];
 	
-	strncpy(name1, name, sizeof(name1)-1);
+	BLI_strncpy(name1, filepath, sizeof(name1));
 	cleanup_path(relabase, name1);
 //	printf("blo_find_main: original in  %s\n", name);
 //	printf("blo_find_main: converted to %s\n", name1);
@@ -511,14 +511,14 @@
 	BLI_addtail(mainlist, m);
 
 	lib= alloc_libblock(&m->library, ID_LI, "lib");
-	strncpy(lib->name, name, sizeof(lib->name)-1);
+	strncpy(lib->name, filepath, sizeof(lib->name)-1);
 	BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
 	
 	m->curlib= lib;
 	
 	read_file_version(fd, m);
 	
-	if(G.f & G_DEBUG) printf("blo_find_main: added new lib %s\n", name);
+	if(G.f & G_DEBUG) printf("blo_find_main: added new lib %s\n", filepath);
 	return m;
 }
 
@@ -944,14 +944,14 @@
 
 /* cannot be called with relative paths anymore! */
 /* on each new library added, it now checks for the current FileData and expands relativeness */
-FileData *blo_openblenderfile(const char *name, ReportList *reports)
+FileData *blo_openblenderfile(const char *filepath, ReportList *reports)
 {
 	gzFile gzfile;
 	errno= 0;
-	gzfile= gzopen(name, "rb");
+	gzfile= gzopen(filepath, "rb");
 
 	if (gzfile == (gzFile)Z_NULL) {
-		BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", name, errno ? strerror(errno) : "Unknown error reading file");
+		BKE_reportf(reports, RPT_ERROR, "Unable to open \"%s\": %s.", filepath, errno ? strerror(errno) : "Unknown error reading file");
 		return NULL;
 	} else {
 		FileData *fd = filedata_new();
@@ -959,7 +959,7 @@
 		fd->read = fd_read_gzip_from_file;
 
 		/* needed for library_append and read_libraries */
-		BLI_strncpy(fd->relabase, name, sizeof(fd->relabase));
+		BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase));
 
 		return blo_decode_and_check(fd, reports);
 	}
@@ -11750,7 +11750,7 @@
 	return bhead;
 }
 
-BlendFileData *blo_read_file_internal(FileData *fd, const char *filename)
+BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
 {
 	BHead *bhead= blo_firstbhead(fd);
 	BlendFileData *bfd;
@@ -11762,7 +11762,7 @@
 	bfd->main->versionfile= fd->fileversion;
 	
 	bfd->type= BLENFILETYPE_BLEND;
-	strncpy(bfd->main->name, filename, sizeof(bfd->main->name)-1);
+	strncpy(bfd->main->name, filepath, sizeof(bfd->main->name)-1);
 
 	while(bhead) {
 		switch(bhead->code) {
@@ -12790,7 +12790,7 @@
 
 /* returns true if the item was found
  * but it may already have already been appended/linked */
-static int append_named_part(const bContext *C, Main *mainl, FileData *fd, const char *name, int idcode, short flag)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list