[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23979] trunk/blender: Continue development of bfile system.

gsr b3d gsr.b3d at infernal-iceberg.com
Mon Oct 19 20:44:09 CEST 2009


Revision: 23979
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23979
Author:   gsrb3d
Date:     2009-10-19 20:44:09 +0200 (Mon, 19 Oct 2009)

Log Message:
-----------
Continue development of bfile system.
Still not usable, but some parts could be made more portable already.
Help welcome for MacOSX and MSWindows calls and paths.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_bfile.h
    trunk/blender/source/blender/blenlib/BLI_util.h
    trunk/blender/source/blender/blenlib/intern/BLI_bfile.c
    trunk/blender/source/blender/blenlib/intern/util.c

Added Paths:
-----------
    trunk/blender/release/environment-macosx
    trunk/blender/release/environment-mswindows
    trunk/blender/release/environment-unix

Added: trunk/blender/release/environment-macosx
===================================================================
--- trunk/blender/release/environment-macosx	                        (rev 0)
+++ trunk/blender/release/environment-macosx	2009-10-19 18:44:09 UTC (rev 23979)
@@ -0,0 +1,18 @@
+# This is a Blender Environment Variable config file.
+#
+# Comment lines start with "#", other lines will be split at the "="
+# and the part before will be used as env var name and the part after
+# as env var value. The value can make reference to previous or
+# prelaunch variables with "${}" and the content will be replaced.
+# Once set, values of variables will not be overwritten.
+#
+# BLENDER_SHARE should be /Library/Application Support/Blender for typical installs.
+# BLENDER_VERSION will be set by the program before processing this file.
+BLENDER_USER_BASE=${HOME}/Library/Application Support/Blender/${BLENDER_VERSION}
+BLENDER_SYSTEM_BASE=${BLENDER_SHARE}/${BLENDER_VERSION}
+BLENDER_USER_DATAFILES=${HOME}/Library/Application Support/Blender/${BLENDER_VERSION}/datafiles
+BLENDER_SYSTEM_DATAFILES=${BLENDER_SHARE}/${BLENDER_VERSION}/datafiles
+BLENDER_USER_PY=${HOME}/Library/Application Support/Blender/${BLENDER_VERSION}/py
+BLENDER_SYSTEM_PY=${BLENDER_SHARE}/${BLENDER_VERSION}/py
+BLENDER_USER_PLUGINS=${HOME}/Library/Application Support/Blender/${BLENDER_VERSION}/plugins
+BLENDER_SYSTEM_PLUGINS=${BLENDER_SHARE}/${BLENDER_VERSION}/plugins


Property changes on: trunk/blender/release/environment-macosx
___________________________________________________________________
Name: svn:eol-style
   + LF

Added: trunk/blender/release/environment-mswindows
===================================================================
--- trunk/blender/release/environment-mswindows	                        (rev 0)
+++ trunk/blender/release/environment-mswindows	2009-10-19 18:44:09 UTC (rev 23979)
@@ -0,0 +1,18 @@
+# This is a Blender Environment Variable config file.
+#
+# Comment lines start with "#", other lines will be split at the "="
+# and the part before will be used as env var name and the part after
+# as env var value. The value can make reference to previous or
+# prelaunch variables with "%%" and the content will be replaced.
+# Once set, values of variables will not be overwritten.
+#
+# BLENDER_SHARE should be COMMON_APPDATA\\Blender Foundation\\Blender for typical installs.
+# BLENDER_VERSION will be set by the program before processing this file.
+BLENDER_USER_BASE=%USERPROFILE%\\Blender Foundation\\Blender\\%BLENDER_VERSION%
+BLENDER_SYSTEM_BASE=%BLENDER_SHARE%\\%BLENDER_VERSION%
+BLENDER_USER_DATAFILES=%USERPROFILE%\\Blender Foundation\\%BLENDER_VERSION%\\datafiles
+BLENDER_SYSTEM_DATAFILES=%BLENDER_SHARE%\\%BLENDER_VERSION%\\datafiles
+BLENDER_USER_PY=%USERPROFILE%\\Blender Foundation\\%BLENDER_VERSION%\\py
+BLENDER_SYSTEM_PY=%BLENDER_SHARE%\\%BLENDER_VERSION%\\py
+BLENDER_USER_PLUGINS=%USERPROFILE%\\Blender Foundation\\%BLENDER_VERSION%\\plugins
+BLENDER_SYSTEM_PLUGINS=%BLENDER_SHARE%\\%BLENDER_VERSION%\\plugins


Property changes on: trunk/blender/release/environment-mswindows
___________________________________________________________________
Name: svn:eol-style
   + CRLF

Added: trunk/blender/release/environment-unix
===================================================================
--- trunk/blender/release/environment-unix	                        (rev 0)
+++ trunk/blender/release/environment-unix	2009-10-19 18:44:09 UTC (rev 23979)
@@ -0,0 +1,18 @@
+# This is a Blender Environment Variable config file.
+#
+# Comment lines start with "#", other lines will be split at the "="
+# and the part before will be used as env var name and the part after
+# as env var value. The value can make reference to previous or
+# prelaunch variables with "${}" and the content will be replaced.
+# Once set, values of variables will not be overwritten.
+#
+# BLENDER_SHARE should be /usr/share/blender for typical distro installs.
+# BLENDER_VERSION will be set by the program before processing this file.
+BLENDER_USER_BASE=${HOME}/.blender/${BLENDER_VERSION}
+BLENDER_SYSTEM_BASE=${BLENDER_SHARE}/${BLENDER_VERSION}
+BLENDER_USER_DATAFILES=${HOME}/.blender/${BLENDER_VERSION}/datafiles
+BLENDER_SYSTEM_DATAFILES=${BLENDER_SHARE}/${BLENDER_VERSION}/datafiles
+BLENDER_USER_PY=${HOME}/.blender/${BLENDER_VERSION}/py
+BLENDER_SYSTEM_PY=${BLENDER_SHARE}/${BLENDER_VERSION}/py
+BLENDER_USER_PLUGINS=${HOME}/.blender/${BLENDER_VERSION}/plugins
+BLENDER_SYSTEM_PLUGINS=${BLENDER_SHARE}/${BLENDER_VERSION}/plugins


Property changes on: trunk/blender/release/environment-unix
___________________________________________________________________
Name: svn:eol-style
   + LF

Modified: trunk/blender/source/blender/blenlib/BLI_bfile.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_bfile.h	2009-10-19 17:50:26 UTC (rev 23978)
+++ trunk/blender/source/blender/blenlib/BLI_bfile.h	2009-10-19 18:44:09 UTC (rev 23979)
@@ -38,9 +38,9 @@
 #define BFILE_NORMAL (0)
 /* No supervision, just translate // if needed, RISKY */
 #define BFILE_RAW    (1<<0)
-/* Path is relative to config dirs */
+/* Path is based in env vars specified by "envvars" */
 #define BFILE_CONFIG (1<<1)
-/* Path is for current session temp file */
+/* Path is for current session temp files */
 #define BFILE_TEMP   (1<<2)
 
 /* Config handling, special cases: */
@@ -51,6 +51,17 @@
 #define BFILE_GZIP (1<<5)
 
 /**
+ For the envvars param.
+ */
+typedef enum BEnvVarFamilies {
+	BENV_NONE,
+	BENV_BASE,
+	BENV_DATAFILES,
+	BENV_PYTHON,
+	BENV_PLUGINS
+} BEnvVarFam;
+
+/**
  File descriptor for Blender abstracted file access.
  */
 typedef struct {
@@ -58,22 +69,23 @@
 	int fd;
 
 	/* Anything below should not be touched directly */
-	int uflags;  /* Special options requested by upper level, copy of bflags */
-	char *fpath; /* Final/requested path name */
-	char *tpath; /* Temp path name if applicable */
-	int type;    /* Own flags, common classification of open and fopen */
-	int error;   /* An op caused an error, unsafe to replace older files */
+	int uflags;       /* Special options requested by upper level, copy of bflags */
+	BEnvVarFam evars; /* What kind of file, describe the env vars to use */
+	char *fpath;      /* Final/requested path name */
+	char *tpath;      /* Temp path name if applicable */
+	int classf;       /* Own flags, common classification of open and fopen */
+	int error;        /* An op caused an error, unsafe to replace older files */
 } BFILE;
 
 /**
  Open a BFILE* with fopen()-like syntax.
  */
-BFILE *BLI_bfile_fopen(const char *path, const char *mode, int bflags);
+BFILE *BLI_bfile_fopen(const char *path, const char *mode, int bflags, BEnvVarFam envvars);
 
 /**
  Open a BFILE* with open()-like syntax.
  */
-BFILE *BLI_bfile_open(const char *pathname, int flags, int bflags);
+BFILE *BLI_bfile_open(const char *pathname, int flags, int bflags, BEnvVarFam envvars);
 
 /**
  Get the FILE* associated with the BFILE*.

Modified: trunk/blender/source/blender/blenlib/BLI_util.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_util.h	2009-10-19 17:50:26 UTC (rev 23978)
+++ trunk/blender/source/blender/blenlib/BLI_util.h	2009-10-19 18:44:09 UTC (rev 23979)
@@ -51,6 +51,7 @@
 #define BLI_GETHOME_ALL			(BLI_GETHOME_SYSTEM|BLI_GETHOME_LOCAL|BLI_GETHOME_USER)
 
 void BLI_setenv(const char *env, const char *val);
+void BLI_setenv_if_new(const char *env, const char* val);
 
 void BLI_make_file_string(const char *relabase, char *string,  const char *dir, const char *file);
 void BLI_make_exist(char *dir);

Modified: trunk/blender/source/blender/blenlib/intern/BLI_bfile.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/BLI_bfile.c	2009-10-19 17:50:26 UTC (rev 23978)
+++ trunk/blender/source/blender/blenlib/intern/BLI_bfile.c	2009-10-19 18:44:09 UTC (rev 23979)
@@ -25,89 +25,70 @@
  */
 
 #include <string.h>
-
+#include <stdlib.h>
 #ifndef WIN32
   #include <unistd.h>
 #else
   #include <io.h>
   #include "BLI_winstuff.h"
 #endif
-
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <libgen.h>
 
 #include "MEM_guardedalloc.h"
-
+#include "BKE_utildefines.h"
+#include "BKE_blender.h"
+#include "BLI_util.h"
+#include "BLI_fileops.h"
+#include "BLI_storage.h"
 #include "BLI_bfile.h"
 
-// This would provide config paths and their oldest viable version
-// so if there is an uncompatible change, user's old versions are not loaded
-//#include "bfile_tables.h"
+/* Internal bfile classification flags */
+#define BCF_OPEN     (0)
+#define BCF_FOPEN    (1<<0)
+#define BCF_READ     (1<<1)
+#define BCF_WRITE    (1<<2)
+#define BCF_AT_END   (1<<3)
+#define BCF_DISCARD  (1<<4)
 
-/* Internal bfile type flags */
-#define BTF_OPEN     (0)
-#define BTF_FOPEN    (1<<0)
-#define BTF_READ     (1<<1)
-#define BTF_WRITE    (1<<2)
-#define BTF_AT_END   (1<<3)
-#define BTF_DISCARD  (1<<4)
+/* Declaration of internal functions */
+void chomp(char* line);
+void expand_envvars(char* src, char* dst);
+void fill_paths(BFILE *bfile, const char *path);
+char* find_in_pathlist(char* filename, char* pathlist);
+void init_vars_from_file(const char* path);
+void setup_temp();
 
+/*** Exported functions ***/
 
-void fill_paths(BFILE *bfile, const char *path) {
-	char* source_path = NULL;
-	int bflags = bfile->uflags;
-
-	if(bflags & BFILE_NORMAL || bflags & BFILE_RAW) {
-//		bfile->fpath is path with // replaced
-	}
-	if(bflags & BFILE_TEMP) {
-//		bfile->fpath is tempdir+path
-	}
-	if(bflags & BFILE_CONFIG) {
-//		bfile->fpath is userdir+version+path
-//		source_path is first hit in (if using fallback to older versions)
-//		    userdir+curversion+path (... userdir+limitversion+path) sysdir+path
-//		(limitversion is based in path, using some kind of regex or "tables")
-	}
-
-	if(bfile->type & BTF_WRITE && !(bflags & BFILE_RAW)) {
-		/* Generate temp path */
-		// bfile->tpath is fpath+randstring
-		if(!(bfile->type & BTF_DISCARD)) {
-			/* Copy data to tpath */
-			if(source_path) {
-				// copy it from older version or sys version
-			}
-		}
-	} else {
-		bfile->tpath = bfile->fpath;
-	}
-}
-
-BFILE *BLI_bfile_fopen(const char *path, const char *mode, int bflags) {
+BFILE *BLI_bfile_fopen(const char *path, const char *mode, int bflags,
+                       BEnvVarFam envvars)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list