svn merge ^/trunk/blender -r41175:41200 --- will need to apply fix after

This commit is contained in:
Campbell Barton 2011-10-24 07:56:42 +00:00
commit ad1d3dd30f
116 changed files with 5710 additions and 5693 deletions

@ -1655,15 +1655,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
return GHOST_kFailure;
}
/* unicode input - not entirely supported yet
* but we are getting the right byte, Blender is not drawing it though
* also some languages may need special treatment:
- Japanese: romanji is used as input, and every 2 letters OSX converts the text
to Hiragana/Katakana.
- Korean: one add one letter at a time, and then the OSX join them in the equivalent
combined letter.
*/
char utf8_buf[6]= {'\0'};
ascii = 0;
switch ([event type]) {
@ -1678,39 +1671,21 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
keyCode = convertKey([event keyCode],0,
[event type] == NSKeyDown?kUCKeyActionDown:kUCKeyActionUp);
/* ascii */
/* handling both unicode or ascii */
characters = [event characters];
if ([characters length]>0) { //Check for dead keys
//Convert characters to iso latin 1 encoding
convertedCharacters = [characters dataUsingEncoding:NSISOLatin1StringEncoding];
if ([convertedCharacters length]>0)
ascii =((char*)[convertedCharacters bytes])[0];
else
ascii = 0; //Character not available in iso latin 1 encoding
}
else
ascii= 0;
/* unicode */
if ([characters length]>0) {
convertedCharacters = [characters dataUsingEncoding:NSUTF8StringEncoding];
if ([convertedCharacters length]>0) {
utf8_buf[0] = ((char*)[convertedCharacters bytes])[0];
utf8_buf[1] = ((char*)[convertedCharacters bytes])[1];
utf8_buf[2] = ((char*)[convertedCharacters bytes])[2];
utf8_buf[3] = ((char*)[convertedCharacters bytes])[3];
utf8_buf[4] = ((char*)[convertedCharacters bytes])[4];
utf8_buf[5] = ((char*)[convertedCharacters bytes])[5];
for (int x = 0; x < [convertedCharacters length]; x++) {
utf8_buf[x] = ((char*)[convertedCharacters bytes])[x];
}
else {
utf8_buf[0] = '\0';
/* ascii is a subset of unicode */
if ([convertedCharacters length] == 1) {
ascii = utf8_buf[0];
}
}
/* XXX the above code gives us the right utf8, however if we pass it along Font Object doesn't work.
let's leave utf8 disabled for OSX before we fix that */
utf8_buf[0] = '\0';//to be removed once things are working
if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
break; //Cmd-Q is directly handled by Cocoa
@ -1718,8 +1693,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii, utf8_buf) );
//printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
} else {
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii, utf8_buf) );
//printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, 0, '\0') );
//printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
}
break;

@ -712,21 +712,23 @@ GHOST_EventKey* GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINP
GHOST_SystemWin32 * system = (GHOST_SystemWin32 *)getSystem();
GHOST_TKey key = system->hardKey(window, raw, &keyDown, &vk);
GHOST_EventKey* event;
if (key != GHOST_kKeyUnknown) {
char ascii = '\0';
char utf8_char[6] = {0} ;
unsigned short utf16[2]={0};
wchar_t utf16[2]={0};
BYTE state[256];
GetKeyboardState((PBYTE)state);
GetKeyboardState((PBYTE)state);
if(ToAsciiEx(vk, 0, state, utf16, 0, system->m_keylayout))
WideCharToMultiByte(CP_ACP, 0x00000400,
if(ToUnicodeEx(vk, 0, state, utf16, 2, 0, system->m_keylayout))
WideCharToMultiByte(CP_UTF8, 0,
(wchar_t*)utf16, 1,
(LPSTR) &ascii, 1,
NULL,NULL);
(LPSTR) utf8_char, 5,
NULL,NULL); else *utf8_char = 0;
/* TODO, last arg is utf8, need to pass utf8 arg */
event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, ascii, NULL);
if(!keyDown) utf8_char[0] = '\0';
event = new GHOST_EventKey(system->getMilliSeconds(), keyDown ? GHOST_kEventKeyDown: GHOST_kEventKeyUp, window, key, (*utf8_char & 0x80)?'?':*utf8_char, utf8_char);
#ifdef GHOST_DEBUG
std::cout << ascii << std::endl;

@ -50,9 +50,8 @@
extern int datatoc_bfont_ttf_size;
extern char datatoc_bfont_ttf[];
// XXX, bad, but BLI uses these
char bprogname[160]= "";
char U[1024]= {0};
/* cheat */
char U[1024]= {0};
#endif
#include "Util.h"

@ -49,14 +49,14 @@
* the Standard Template Library but without the painful get()
* semantics to access the internal c style pointer.
*
* It is often useful to explicitely decalre ownership of memory
* It is often useful to explicitly declare ownership of memory
* allocated on the heap within class or function scope. This
* class helps you to encapsulate this ownership within a value
* type. When an instance of this class goes out of scope it
* makes sure that any memory associated with it's internal pointer
* is deleted. It can help to inform users of an aggregate class
* that it owns instances of it's members and these instances
* should not be shared. This is not reliably enforcable in C++
* should not be shared. This is not reliably enforceable in C++
* but this class attempts to make the 1-1 relationship clear.
*
* @section Example usage

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 150 KiB

@ -136,7 +136,7 @@ char *blf_dir_search(const char *file)
for(dir=global_font_dir.first; dir; dir= dir->next) {
BLI_join_dirfile(full_path, sizeof(full_path), dir->path, file);
if (BLI_exist(full_path)) {
if (BLI_exists(full_path)) {
s= BLI_strdup(full_path);
break;
}
@ -144,7 +144,7 @@ char *blf_dir_search(const char *file)
if (!s) {
/* check the current directory, why not ? */
if (BLI_exist(file))
if (BLI_exists(file))
s= BLI_strdup(file);
}
@ -198,13 +198,13 @@ char *blf_dir_metrics_search(const char *filename)
s[2]= 'm';
/* first check .afm */
if (BLI_exist(s))
if (BLI_exists(s))
return s;
/* and now check .pfm */
s[0]= 'p';
if (BLI_exist(s))
if (BLI_exists(s))
return s;
}
MEM_freeN(mfile);

@ -55,6 +55,7 @@
#include "BLI_linklist.h" /* linknode */
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_path_util.h"
#define DOMAIN_NAME "blender"

@ -60,7 +60,7 @@ unsigned char *BLF_get_unifont(int *unifont_size_r)
BLI_snprintf(unifont_path, sizeof(unifont_path), "%s/%s", fontpath, unifont_filename);
unifont_ttf= (unsigned char*)BLI_ungzip_to_mem(unifont_path, &unifont_size);
unifont_ttf= (unsigned char*)BLI_file_ungzip_to_mem(unifont_path, &unifont_size);
}
else {
printf("%s: 'fonts' data path not found for international font, continuing\n", __func__);

@ -34,7 +34,6 @@
*/
#include "BLI_kdopbvh.h"
#include "BLI_linklist.h"
/*
* This header encapsulates necessary code to buld a BVH
@ -118,7 +117,7 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data);
#define BVHTREE_FROM_VERTICES 1
#define BVHTREE_FROM_EDGES 2
typedef LinkNode* BVHCache;
typedef struct LinkNode* BVHCache;
/*

@ -51,6 +51,7 @@
#include "BLI_array.h"
#include "BLI_pbvh.h"
#include "BLI_utildefines.h"
#include "BLI_linklist.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_displist.h"

@ -549,7 +549,7 @@ void BKE_write_undo(bContext *C, const char *name)
counter= counter % U.undosteps;
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
BLI_make_file_string("/", filepath, btempdir, numstr);
BLI_make_file_string("/", filepath, BLI_temporary_dir(), numstr);
/* success= */ /* UNUSED */ BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL);
@ -705,7 +705,7 @@ void BKE_undo_save_quit(void)
{
char str[FILE_MAXDIR+FILE_MAXFILE];
BLI_make_file_string("/", str, btempdir, "quit.blend");
BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
BKE_undo_save(str);
}

@ -40,6 +40,7 @@
#include "BLI_editVert.h"
#include "BLI_utildefines.h"
#include "BLI_linklist.h"
#include "BKE_DerivedMesh.h"
#include "BKE_tessmesh.h"

@ -41,6 +41,7 @@
#include "BLI_math.h"
#include "BLI_edgehash.h"
#include "BLI_utildefines.h"
#include "BLI_linklist.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_cloth.h"

@ -41,7 +41,6 @@
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BLI_utildefines.h"

@ -48,7 +48,6 @@
#include "BLI_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_path_util.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLI_mempool.h"

@ -33,7 +33,6 @@
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <math.h>
#include <stdlib.h>
@ -59,8 +58,6 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_jitter.h"
#include "BLI_listbase.h"
#include "BLI_noise.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"

@ -33,7 +33,6 @@
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include "MEM_guardedalloc.h"

@ -54,6 +54,7 @@
#include "BLI_utildefines.h"
#include "BLI_path_util.h"
#include "BLI_listbase.h"
#include "BLI_linklist.h"
#include "BLI_string.h"
#include "BKE_bmesh.h"

@ -192,7 +192,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char
if (file <= 0) {
BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name);
} else {
filelen = BLI_filesize(file);
filelen = BLI_file_descriptor_size(file);
if (filelen == 0) {
// MEM_mallocN complains about MEM_mallocN(0, "bla");
@ -283,7 +283,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i
for (number = 1; number <= 999; number++) {
BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number);
if (! BLI_exists(tempname)) {
if (BLI_copy_fileops(name, tempname) == RET_OK) {
if (BLI_copy(name, tempname) == RET_OK) {
remove_tmp = TRUE;
}
break;

@ -54,6 +54,7 @@
#include "BLI_kdtree.h"
#include "BLI_rand.h"
#include "BLI_threads.h"
#include "BLI_linklist.h"
#include "BLI_cellalloc.h"
#include "BLI_math.h"

@ -36,7 +36,6 @@
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <stdlib.h>
#include <math.h>
@ -66,10 +65,9 @@
#include "BLI_blenlib.h"
#include "BLI_kdtree.h"
#include "BLI_kdopbvh.h"
#include "BLI_listbase.h"
#include "BLI_threads.h"
#include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */
#include "BLI_utildefines.h"
#include "BLI_linklist.h"
#include "BLI_edgehash.h"
#include "BKE_main.h"

@ -923,8 +923,8 @@ static int ptcache_path(PTCacheID *pid, char *filename)
}
/* use the temp path. this is weak but better then not using point cache at all */
/* btempdir is assumed to exist and ALWAYS has a trailing slash */
BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", btempdir, abs(getpid()));
/* temporary directory is assumed to exist and ALWAYS has a trailing slash */
BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", BLI_temporary_dir(), abs(getpid()));
return BLI_add_slash(filename); /* new strlen() */
}
@ -2363,7 +2363,7 @@ void BKE_ptcache_remove(void)
ptcache_path(NULL, path);
if (BLI_exist(path)) {
if (BLI_exists(path)) {
/* The pointcache dir exists? - remove all pointcache */
DIR *dir;

@ -61,9 +61,10 @@
#include "BKE_sequencer.h"
#include "BKE_fcurve.h"
#include "BKE_scene.h"
#include "RNA_access.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
#include "RE_pipeline.h"
#include <pthread.h>

@ -146,7 +146,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAgin
ccgSubSurf_setUseAgeCounts(ccgSS, 1, 8, 8, 8);
}
ccgSubSurf_setCalcVertexNormals(ccgSS, 1, BLI_STRUCT_OFFSET(DMGridData, no));
ccgSubSurf_setCalcVertexNormals(ccgSS, 1, offsetof(DMGridData, no));
return ccgSS;
}

@ -64,8 +64,6 @@ struct ListBase;
#include <stdlib.h>
extern char btempdir[]; /* creator.c temp dir used instead of U.tempdir, set with BLI_where_is_temp( btempdir, 1 ); */
#ifdef __cplusplus
extern "C" {
#endif
@ -78,21 +76,12 @@ extern "C" {
#include "BLI_path_util.h"
#include "BLI_storage.h"
#include "BLI_fileops.h"
#include "BLI_rect.h"
#include "BLI_noise.h"
/**
* @param strct The structure of interest
* @param member The name of a member field of @a strct
* @retval The offset in bytes of @a member within @a strct
*/
#define BLI_STRUCT_OFFSET(strct, member) ((int)(intptr_t) &((strct*) 0)->member)
#ifdef __cplusplus
}
#endif

@ -30,7 +30,7 @@
#ifndef BLI_EDGEHASH_H
#define BLI_EDGEHASH_H
/** \file BLI_storage.h
/** \file BLI_edgehash.h
* \ingroup bli
* \author Daniel Dunbar
* \brief A general unordered 2-int pair hash table ADT.

@ -29,10 +29,7 @@
/** \file BLI_fileops.h
* \ingroup bli
* \author Daniel Dunbar
* \brief More low-level fileops from Daniel Dunbar. Two functions were also
* defined in storage.c. These are the old fop_ prefixes. There is
* definitely some redundancy here!
* \brief File and directory operations.
* */
#ifndef BLI_FILEOPS_H
@ -42,26 +39,48 @@
extern "C" {
#endif
void BLI_recurdir_fileops(const char *dirname);
int BLI_link(const char *file, const char *to);
int BLI_is_writable(const char *filename);
#include "BLI_fileops_types.h"
/**
* @attention Do not confuse with BLI_exist [joeedh--yet, it calls BLI_exist?]
*/
int BLI_exists(const char *file);
int BLI_copy_fileops(const char *file, const char *to);
int BLI_rename(const char *from, const char *to);
int BLI_gzip(const char *from, const char *to);
char *BLI_ungzip_to_mem(const char *from_file, int *size_r);
int BLI_delete(const char *file, int dir, int recursive);
int BLI_move(const char *file, const char *to);
int BLI_touch(const char *file);
/* for size_t (needed on windows) */
#include <stddef.h>
/* only for the sane unix world: direct calls to system functions :( */
#ifndef WIN32
void BLI_setCmdCallBack(int (*f)(char*));
#endif
/* Common */
int BLI_exists(const char *path);
int BLI_copy(const char *path, const char *to);
int BLI_rename(const char *from, const char *to);
int BLI_delete(const char *path, int dir, int recursive);
int BLI_move(const char *path, const char *to);
int BLI_create_symlink(const char *path, const char *to);
/* Directories */
struct direntry;
int BLI_is_dir(const char *path);
void BLI_dir_create_recursive(const char *dir);
double BLI_dir_free_space(const char *dir);
char *BLI_current_working_dir(char *dir, const int maxlen);
unsigned int BLI_dir_contents(const char *dir, struct direntry **filelist);
/* Files */
int BLI_file_is_writable(const char *file);
int BLI_file_touch(const char *file);
int BLI_file_gzip(const char *from, const char *to);
char *BLI_file_ungzip_to_mem(const char *from_file, int *size_r);
size_t BLI_file_descriptor_size(int file);
size_t BLI_file_size(const char *file);
/* compare if one was last modified before the other */
int BLI_file_older(const char *file1, const char *file2);
/* read ascii file as lines, empty list if reading fails */
struct LinkNode *BLI_file_read_as_lines(const char *file);
void BLI_file_free_lines(struct LinkNode *lines);
#ifdef __cplusplus
}

@ -26,10 +26,11 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BLI_STORAGE_TYPES_H
#define BLI_STORAGE_TYPES_H
/** \file BLI_storage_types.h
#ifndef BLI_FILEOPS_TYPES_H
#define BLI_FILEOPS_TYPES_H
/** \file BLI_fileops_types.h
* \ingroup bli
* \brief Some types for dealing with directories.
*/
@ -75,5 +76,5 @@ struct dirlink
char *name;
};
#endif /* BLI_STORAGE_TYPES_H */
#endif /* BLI_FILEOPS_TYPES_H */

@ -65,10 +65,6 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check);
#define BLENDER_SYSTEM_PLUGINS 54
#define BLENDER_SYSTEM_PYTHON 54
#define BLENDER_TEMP 80
#define BLENDER_USERFOLDER(id) (id >= BLENDER_USER_CONFIG && id <= BLENDER_USER_PLUGINS)
/* for BLI_get_folder_version only */
#define BLENDER_RESOURCE_PATH_USER 0
#define BLENDER_RESOURCE_PATH_LOCAL 1
@ -78,17 +74,6 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check);
#define BLENDER_BOOKMARK_FILE "bookmarks.txt"
#define BLENDER_HISTORY_FILE "recent-files.txt"
#ifdef WIN32
#define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s"
#define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s"
#elif defined(__APPLE__)
#define BLENDER_USER_FORMAT "%s/Blender/%s"
#define BLENDER_SYSTEM_FORMAT "%s/Blender/%s"
#else
#define BLENDER_USER_FORMAT "%s/.blender/%s"
#define BLENDER_SYSTEM_FORMAT "%s/blender/%s"
#endif
#ifdef WIN32
#define SEP '\\'
#define ALTSEP '/'
@ -181,29 +166,20 @@ void BLI_path_rel(char *file, const char *relfile);
*/
void BLI_char_switch(char *string, char from, char to);
/**
* Checks if name is a fully qualified filename to an executable.
* If not it searches $PATH for the file. On Windows it also
* adds the correct extension (.com .exe etc) from
* $PATHEXT if necessary. Also on Windows it translates
* the name to its 8.3 version to prevent problems with
* spaces and stuff. Final result is returned in fullname.
*
* @param fullname The full path and full name of the executable
* @param name The name of the executable (usually argv[0]) to be checked
*/
void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name);
/**
* Gets the temp directory when blender first runs.
* If the default path is not found, use try $TEMP
*
* Also make sure the temp dir has a trailing slash
*
* @param fullname The full path to the temp directory
*/
void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp);
/* Initialize path to program executable */
void BLI_init_program_path(const char *argv0);
/* Initialize path to temporary directory.
* NOTE: On Window userdir will be set to the temporary directory! */
void BLI_init_temporary_dir(char *userdir);
/* Path to executable */
const char *BLI_program_path(void);
/* Path to directory of executable */
const char *BLI_program_dir(void);
/* Path to temporary directory (with trailing slash) */
const char *BLI_temporary_dir(void);
/* Path to the system temporary directory (with trailing slash) */
void BLI_system_temporary_dir(char *dir);
#ifdef WITH_ICONV
void BLI_string_to_utf8(char *original, char *utf_8, const char *code);

@ -30,7 +30,7 @@
#ifndef BLI_SCANFILL_H
#define BLI_SCANFILL_H
/** \file BLI_storage.h
/** \file BLI_scanfill.h
* \ingroup bli
* \since March 2001
* \author nzc

@ -1,82 +0,0 @@
/* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BLI_STORAGE_H
#define BLI_STORAGE_H
/** \file BLI_storage.h
* \ingroup bli
*/
#ifdef WIN32
/* for size_t, only needed on win32 for some reason */
#include <stddef.h>
#endif
struct direntry;
void BLI_adddirstrings(void);
void BLI_builddir(const char *dirname, const char *relname);
int BLI_compare(struct direntry *entry1, struct direntry *entry2);
size_t BLI_filesize(int file);
size_t BLI_filepathsize(const char *path);
double BLI_diskfree(const char *dir);
char *BLI_getwdN(char *dir, const int maxncpy);
unsigned int BLI_getdir(const char *dirname, struct direntry **filelist);
/**
* @attention Do not confuse with BLI_exists
*/
int BLI_exist(const char *name);
/**
* Read a file as ASCII lines. An empty list is
* returned if the file cannot be opened or read.
*
* @attention The returned list should be free'd with
* BLI_free_file_lines.
*
* @param name The name of the file to read.
* @retval A list of strings representing the file lines.
*/
int BLI_is_dir(const char *file);
struct LinkNode *BLI_read_file_as_lines(const char *name);
/**
* Free the list returned by BLI_read_file_as_lines.
*/
void BLI_free_file_lines(struct LinkNode *lines);
/* Compare if one was last modified before the other */
int BLI_file_older(const char *file1, const char *file2);
#endif /* BLI_STORAGE_H */

@ -67,64 +67,113 @@
#define MAX3(x,y,z) MAX2( MAX2((x),(y)) , (z) )
#define MAX4(x,y,z,a) MAX2( MAX2((x),(y)) , MAX2((z),(a)) )
#define INIT_MINMAX(min, max) { (min)[0]= (min)[1]= (min)[2]= 1.0e30f; (max)[0]= (max)[1]= (max)[2]= -1.0e30f; }
#define INIT_MINMAX2(min, max) { (min)[0]= (min)[1]= 1.0e30f; (max)[0]= (max)[1]= -1.0e30f; }
#define DO_MIN(vec, min) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; } \
#define DO_MAX(vec, max) { if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; } \
#define DO_MINMAX(vec, min, max) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; } \
#define DO_MINMAX2(vec, min, max) { if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; }
#define INIT_MINMAX(min, max) { \
(min)[0]= (min)[1]= (min)[2]= 1.0e30f; \
(max)[0]= (max)[1]= (max)[2]= -1.0e30f; \
}
#define INIT_MINMAX2(min, max) { \
(min)[0]= (min)[1]= 1.0e30f; \
(max)[0]= (max)[1]= -1.0e30f; \
}
#define DO_MIN(vec, min) { \
if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \
}
#define DO_MAX(vec, max) { \
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; \
}
#define DO_MINMAX(vec, min, max) { \
if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; \
}
#define DO_MINMAX2(vec, min, max) { \
if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
}
/* some math and copy defines */
#ifndef SWAP
# define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
# define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
#endif
#define ABS(a) ( (a)<0 ? (-(a)) : (a) )
#define AVG2(x, y) ( 0.5 * ((x) + (y)) )
#define ABS(a) ( (a)<0 ? (-(a)) : (a) )
#define FTOCHAR(val) ((val)<=0.0f)? 0 : (((val)>(1.0f-0.5f/255.0f))? 255 : (char)((255.0f*(val))+0.5f))
#define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f))
#define F3TOCHAR3(v2,v1) (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2]))
#define F3TOCHAR4(v2,v1) { (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2])); \
(v1)[3] = 255; }
#define F4TOCHAR4(v2,v1) { (v1)[0]=FTOCHAR((v2[0])); (v1)[1]=FTOCHAR((v2[1])); (v1)[2]=FTOCHAR((v2[2])); \
(v1)[3]=FTOCHAR((v2[3])); }
#define F3TOCHAR3(v2, v1) { \
(v1)[0]= FTOCHAR((v2[0])); \
(v1)[1]= FTOCHAR((v2[1])); \
(v1)[2]= FTOCHAR((v2[2])); \
}
#define F3TOCHAR4(v2, v1) { \
(v1)[0]= FTOCHAR((v2[0])); \
(v1)[1]= FTOCHAR((v2[1])); \
(v1)[2]= FTOCHAR((v2[2])); \
(v1)[3]= 255; \
}
#define F4TOCHAR4(v2, v1) { \
(v1)[0]= FTOCHAR((v2[0])); \
(v1)[1]= FTOCHAR((v2[1])); \
(v1)[2]= FTOCHAR((v2[2])); \
(v1)[3]= FTOCHAR((v2[3])); \
}
#define VECCOPY(v1, v2) { \
*(v1)= *(v2); \
*(v1+1)= *(v2+1); \
*(v1+2)= *(v2+2); \
}
#define VECCOPY2D(v1, v2) { \
*(v1)= *(v2); \
*(v1+1)= *(v2+1); \
}
#define QUATCOPY(v1, v2) { \
*(v1)= *(v2); \
*(v1+1)= *(v2+1); \
*(v1+2)= *(v2+2); \
*(v1+3)= *(v2+3); \
}
#define VECADD(v1,v2,v3) { \
*(v1)= *(v2) + *(v3); \
*(v1+1)= *(v2+1) + *(v3+1); \
*(v1+2)= *(v2+2) + *(v3+2); \
}
#define VECSUB(v1,v2,v3) { \
*(v1)= *(v2) - *(v3); \
*(v1+1)= *(v2+1) - *(v3+1); \
*(v1+2)= *(v2+2) - *(v3+2); \
}
#define VECSUB2D(v1,v2,v3) { \
*(v1)= *(v2) - *(v3); \
*(v1+1)= *(v2+1) - *(v3+1); \
}
#define VECADDFAC(v1,v2,v3,fac) { \
*(v1)= *(v2) + *(v3)*(fac); \
*(v1+1)= *(v2+1) + *(v3+1)*(fac); \
*(v1+2)= *(v2+2) + *(v3+2)*(fac); \
}
#define VECSUBFAC(v1,v2,v3,fac) { \
*(v1)= *(v2) - *(v3)*(fac); \
*(v1+1)= *(v2+1) - *(v3+1)*(fac); \
*(v1+2)= *(v2+2) - *(v3+2)*(fac); \
}
#define QUATADDFAC(v1,v2,v3,fac) { \
*(v1)= *(v2) + *(v3)*(fac); \
*(v1+1)= *(v2+1) + *(v3+1)*(fac); \
*(v1+2)= *(v2+2) + *(v3+2)*(fac); \
*(v1+3)= *(v2+3) + *(v3+3)*(fac); \
}
#define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
#define VECCOPY2D(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1);}
#define QUATCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
#define LONGCOPY(a, b, c) {int lcpc=c, *lcpa=(int *)a, *lcpb=(int *)b; while(lcpc-->0) *(lcpa++)= *(lcpb++);}
#define VECADD(v1,v2,v3) {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);}
#define VECSUB(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
#define VECSUB2D(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1);}
#define VECINTERP(v1,v2,v3, fac) {*(v1) = *(v2) + (*(v3)-*(v2))*(fac); *(v1+1) = *(v2+1) + (*(v3+1)-*(v2+1))*(fac); *(v1+2) = *(v2+2) + (*(v3+2)-*(v2+2))*(fac);}
#define VECADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac);}
#define VECSUBFAC(v1,v2,v3,fac) {*(v1)= *(v2) - *(v3)*(fac); *(v1+1)= *(v2+1) - *(v3+1)*(fac); *(v1+2)= *(v2+2) - *(v3+2)*(fac);}
#define QUATADDFAC(v1,v2,v3,fac) {*(v1)= *(v2) + *(v3)*(fac); *(v1+1)= *(v2+1) + *(v3+1)*(fac); *(v1+2)= *(v2+2) + *(v3+2)*(fac); *(v1+3)= *(v2+3) + *(v3+3)*(fac);}
#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
/* some misc stuff.... */
#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c)
@ -139,28 +188,36 @@
#define IN_RANGE_INCL(a, b, c) ((b < c)? ((b<=a && a<=c)? 1:0) : ((c<=a && a<=b)? 1:0))
/* array helpers */
#define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot) (arr_dtype *)((char*)arr_start + (elem_size*(tot - 1)))
#define ARRAY_HAS_ITEM(item, arr_start, arr_dtype, elem_size, tot) ((item >= arr_start) && (item <= ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot)))
#define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot) \
(arr_dtype *)((char*)arr_start + (elem_size*(tot - 1)))
#define ARRAY_HAS_ITEM(item, arr_start, arr_dtype, elem_size, tot) ( \
(item >= arr_start) && \
(item <= ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot)) \
)
/* This one rotates the bytes in an int64, int (32) and short (16) */
#define SWITCH_INT64(a) { \
char s_i, *p_i; \
p_i= (char *)&(a); \
s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \
s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \
s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \
s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; }
#define SWITCH_INT64(a) { \
char s_i, *p_i; \
p_i= (char *)&(a); \
s_i= p_i[0]; p_i[0]= p_i[7]; p_i[7]= s_i; \
s_i= p_i[1]; p_i[1]= p_i[6]; p_i[6]= s_i; \
s_i= p_i[2]; p_i[2]= p_i[5]; p_i[5]= s_i; \
s_i= p_i[3]; p_i[3]= p_i[4]; p_i[4]= s_i; \
}
#define SWITCH_INT(a) { \
char s_i, *p_i; \
p_i= (char *)&(a); \
s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \
s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; }
#define SWITCH_INT(a) { \
char s_i, *p_i; \
p_i= (char *)&(a); \
s_i= p_i[0]; p_i[0]= p_i[3]; p_i[3]= s_i; \
s_i= p_i[1]; p_i[1]= p_i[2]; p_i[2]= s_i; \
}
#define SWITCH_SHORT(a) { \
char s_i, *p_i; \
p_i= (char *)&(a); \
s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; }
#define SWITCH_SHORT(a) { \
char s_i, *p_i; \
p_i= (char *)&(a); \
s_i=p_i[0]; p_i[0]=p_i[1]; p_i[1]=s_i; \
}
/* Warning-free macros for storing ints in pointers. Use these _only_
@ -222,25 +279,25 @@
# else
# define _dummy_abort() (void)0
# endif
# if defined(__GNUC__) || defined(_MSC_VER) /* just want to check if __func__ is available */
# define BLI_assert(a) \
do { \
if (!(a)) { \
fprintf(stderr, \
"BLI_assert failed: %s, %s(), %d at \'%s\'\n", \
__FILE__, __func__, __LINE__, STRINGIFY(a)); \
_dummy_abort(); \
} \
# if defined(__GNUC__) || defined(_MSC_VER) /* check __func__ is available */
# define BLI_assert(a) \
do { \
if (!(a)) { \
fprintf(stderr, \
"BLI_assert failed: %s, %s(), %d at \'%s\'\n", \
__FILE__, __func__, __LINE__, STRINGIFY(a)); \
_dummy_abort(); \
} \
} while (0)
# else
# define BLI_assert(a) \
do { \
if (0 == (a)) { \
fprintf(stderr, \
"BLI_assert failed: %s, %d at \'%s\'\n", \
__FILE__, __LINE__, STRINGIFY(a)); \
_dummy_abort(); \
} \
do { \
if (0 == (a)) { \
fprintf(stderr, \
"BLI_assert failed: %s, %d at \'%s\'\n", \
__FILE__, __LINE__, STRINGIFY(a)); \
_dummy_abort(); \
} \
} while (0)
# endif
#else

@ -105,6 +105,7 @@ set(SRC
BLI_edgehash.h
BLI_editVert.h
BLI_fileops.h
BLI_fileops_types.h
BLI_fnmatch.h
BLI_ghash.h
BLI_graph.h
@ -131,8 +132,6 @@ set(SRC
BLI_rand.h
BLI_rect.h
BLI_scanfill.h
BLI_storage.h
BLI_storage_types.h
BLI_string.h
BLI_string_utf8.h
BLI_threads.h

@ -65,7 +65,8 @@
return -1 if zlib fails, -2 if the originating file does not exist
note: will remove the "from" file
*/
int BLI_gzip(const char *from, const char *to) {
int BLI_file_gzip(const char *from, const char *to)
{
char buffer[10240];
int file;
int readsize = 0;
@ -109,7 +110,7 @@ int BLI_gzip(const char *from, const char *to) {
/* gzip the file in from_file and write it to memery to_mem, at most size bytes.
return the unziped size
*/
char *BLI_ungzip_to_mem(const char *from_file, int *size_r)
char *BLI_file_ungzip_to_mem(const char *from_file, int *size_r)
{
gzFile gzfile;
int readsize, size, alloc_size=0;
@ -150,7 +151,7 @@ char *BLI_ungzip_to_mem(const char *from_file, int *size_r)
/* return 1 when file can be written */
int BLI_is_writable(const char *filename)
int BLI_file_is_writable(const char *filename)
{
int file;
@ -178,7 +179,7 @@ int BLI_is_writable(const char *filename)
}
}
int BLI_touch(const char *file)
int BLI_file_touch(const char *file)
{
FILE *f = fopen(file,"r+b");
if (f != NULL) {
@ -195,15 +196,12 @@ int BLI_touch(const char *file)
return 0;
}
int BLI_exists(const char *file) {
return BLI_exist(file);
}
#ifdef WIN32
static char str[MAXPATHLEN+12];
int BLI_delete(const char *file, int dir, int recursive) {
int BLI_delete(const char *file, int dir, int recursive)
{
int err;
if (recursive) {
@ -220,7 +218,8 @@ int BLI_delete(const char *file, int dir, int recursive) {
return err;
}
int BLI_move(const char *file, const char *to) {
int BLI_move(const char *file, const char *to)
{
int err;
// windows doesn't support moveing to a directory
@ -245,7 +244,8 @@ int BLI_move(const char *file, const char *to) {
}
int BLI_copy_fileops(const char *file, const char *to) {
int BLI_copy(const char *file, const char *to)
{
int err;
// windows doesn't support copying to a directory
@ -270,14 +270,16 @@ int BLI_copy_fileops(const char *file, const char *to) {
return err;
}
int BLI_link(const char *file, const char *to) {
int BLI_create_symlink(const char *file, const char *to)
{
callLocalErrorCallBack("Linking files is unsupported on Windows");
(void)file;
(void)to;
return 1;
}
void BLI_recurdir_fileops(const char *dirname) {
void BLI_dir_create_recursive(const char *dirname)
{
char *lslash;
char tmp[MAXPATHLEN];
@ -299,7 +301,7 @@ void BLI_recurdir_fileops(const char *dirname) {
if (lslash) {
/* Split about the last slash and recurse */
*lslash = 0;
BLI_recurdir_fileops(tmp);
BLI_dir_create_recursive(tmp);
}
if(dirname[0]) /* patch, this recursive loop tries to create a nameless directory */
@ -307,7 +309,8 @@ void BLI_recurdir_fileops(const char *dirname) {
callLocalErrorCallBack("Unable to create directory\n");
}
int BLI_rename(const char *from, const char *to) {
int BLI_rename(const char *from, const char *to)
{
if (!BLI_exists(from)) return 0;
/* make sure the filenames are different (case insensitive) before removing */
@ -347,25 +350,29 @@ int BLI_delete(const char *file, int dir, int recursive)
return -1;
}
int BLI_move(const char *file, const char *to) {
int BLI_move(const char *file, const char *to)
{
BLI_snprintf(str, sizeof(str), "/bin/mv -f \"%s\" \"%s\"", file, to);
return system(str);
}
int BLI_copy_fileops(const char *file, const char *to) {
int BLI_copy(const char *file, const char *to)
{
BLI_snprintf(str, sizeof(str), "/bin/cp -rf \"%s\" \"%s\"", file, to);
return system(str);
}
int BLI_link(const char *file, const char *to) {
int BLI_create_symlink(const char *file, const char *to)
{
BLI_snprintf(str, sizeof(str), "/bin/ln -f \"%s\" \"%s\"", file, to);
return system(str);
}
void BLI_recurdir_fileops(const char *dirname) {
void BLI_dir_create_recursive(const char *dirname)
{
char *lslash;
char tmp[MAXPATHLEN];
@ -377,13 +384,14 @@ void BLI_recurdir_fileops(const char *dirname) {
if (lslash) {
/* Split about the last slash and recurse */
*lslash = 0;
BLI_recurdir_fileops(tmp);
BLI_dir_create_recursive(tmp);
}
mkdir(dirname, 0777);
}
int BLI_rename(const char *from, const char *to) {
int BLI_rename(const char *from, const char *to)
{
if (!BLI_exists(from)) return 0;
if (BLI_exists(to)) if(BLI_delete(to, 0, 0)) return 1;
@ -392,3 +400,4 @@ int BLI_rename(const char *from, const char *to) {
}
#endif

@ -42,13 +42,11 @@
#include "MEM_guardedalloc.h"
#include "DNA_userdef_types.h"
#include "DNA_listBase.h"
#include "BLI_fileops.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BLI_storage.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "BKE_utildefines.h"
@ -85,11 +83,24 @@
#endif /* WIN32 */
/* standard paths */
#ifdef WIN32
#define BLENDER_USER_FORMAT "%s\\Blender Foundation\\Blender\\%s"
#define BLENDER_SYSTEM_FORMAT "%s\\Blender Foundation\\Blender\\%s"
#elif defined(__APPLE__)
#define BLENDER_USER_FORMAT "%s/Blender/%s"
#define BLENDER_SYSTEM_FORMAT "%s/Blender/%s"
#else
#define BLENDER_USER_FORMAT "%s/.blender/%s"
#define BLENDER_SYSTEM_FORMAT "%s/blender/%s"
#endif
/* local */
#define UNIQUE_NAME_MAX 128
extern char bprogname[];
extern char bprogdir[];
static char bprogname[FILE_MAX]; /* path to program executable */
static char bprogdir[FILE_MAX]; /* path in which executable is located */
static char btempdir[FILE_MAX]; /* temporary directory */
static int add_win32_extension(char *name);
static char *blender_version_decimal(const int ver);
@ -728,7 +739,7 @@ int BLI_path_cwd(char *path)
if (wasrelative==1) {
char cwd[FILE_MAXDIR + FILE_MAXFILE]= "";
BLI_getwdN(cwd, sizeof(cwd)); /* incase the full path to the blend isnt used */
BLI_current_working_dir(cwd, sizeof(cwd)); /* incase the full path to the blend isnt used */
if (cwd[0] == '\0') {
printf( "Could not get the current working directory - $PWD for an unknown reason.");
@ -974,7 +985,7 @@ static int get_path_system(char *targetpath, const char *folder_name, const char
}
/* try CWD/release/folder_name */
if(BLI_getwdN(cwd, sizeof(cwd))) {
if(BLI_current_working_dir(cwd, sizeof(cwd))) {
if(test_path(targetpath, cwd, "release", relfolder)) {
return 1;
}
@ -1105,7 +1116,7 @@ char *BLI_get_folder_create(int folder_id, const char *subfolder)
if (!path) {
path = BLI_get_user_folder_notest(folder_id, subfolder);
if (path) BLI_recurdir_fileops(path);
if (path) BLI_dir_create_recursive(path);
}
return path;
@ -1238,7 +1249,7 @@ void BLI_make_existing_file(const char *name)
/* test exist */
if (BLI_exists(di) == 0) {
BLI_recurdir_fileops(di);
BLI_dir_create_recursive(di);
}
}
@ -1635,7 +1646,7 @@ static int add_win32_extension(char *name)
int retval = 0;
int type;
type = BLI_exist(name);
type = BLI_exists(name);
if ((type == 0) || S_ISDIR(type)) {
#ifdef _WIN32
char filename[FILE_MAXDIR+FILE_MAXFILE];
@ -1655,7 +1666,7 @@ static int add_win32_extension(char *name)
strcat(filename, extensions);
}
type = BLI_exist(filename);
type = BLI_exists(filename);
if (type && (! S_ISDIR(type))) {
retval = 1;
strcpy(name, filename);
@ -1671,8 +1682,19 @@ static int add_win32_extension(char *name)
return (retval);
}
/* filename must be FILE_MAX length minimum */
void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name)
/*
* Checks if name is a fully qualified filename to an executable.
* If not it searches $PATH for the file. On Windows it also
* adds the correct extension (.com .exe etc) from
* $PATHEXT if necessary. Also on Windows it translates
* the name to its 8.3 version to prevent problems with
* spaces and stuff. Final result is returned in fullname.
*
* @param fullname The full path and full name of the executable
* (must be FILE_MAX minimum)
* @param name The name of the executable (usually argv[0]) to be checked
*/
static void bli_where_am_i(char *fullname, const size_t maxlen, const char *name)
{
char filename[FILE_MAXDIR+FILE_MAXFILE];
const char *path = NULL, *temp;
@ -1709,7 +1731,7 @@ void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name)
BLI_strncpy(fullname, name, maxlen);
if (name[0] == '.') {
char wdir[FILE_MAX]= "";
BLI_getwdN(wdir, sizeof(wdir)); /* backup cwd to restore after */
BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */
// not needed but avoids annoying /./ in name
if(name[1]==SEP)
@ -1752,12 +1774,37 @@ void BLI_where_am_i(char *fullname, const size_t maxlen, const char *name)
}
}
void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp)
void BLI_init_program_path(const char *argv0)
{
bli_where_am_i(bprogname, sizeof(bprogname), argv0);
BLI_split_dir_part(bprogname, bprogdir, sizeof(bprogdir));
}
const char *BLI_program_path(void)
{
return bprogname;
}
const char *BLI_program_dir(void)
{
return bprogdir;
}
/**
* Gets the temp directory when blender first runs.
* If the default path is not found, use try $TEMP
*
* Also make sure the temp dir has a trailing slash
*
* @param fullname The full path to the temp directory
* @param userdir Directory specified in user preferences
*/
void BLI_where_is_temp(char *fullname, const size_t maxlen, char *userdir)
{
fullname[0] = '\0';
if (usertemp && BLI_is_dir(U.tempdir)) {
BLI_strncpy(fullname, U.tempdir, maxlen);
if (userdir && BLI_is_dir(userdir)) {
BLI_strncpy(fullname, userdir, maxlen);
}
@ -1791,13 +1838,28 @@ void BLI_where_is_temp(char *fullname, const size_t maxlen, int usertemp)
/* add a trailing slash if needed */
BLI_add_slash(fullname);
#ifdef WIN32
if(U.tempdir != fullname) {
BLI_strncpy(U.tempdir, fullname, maxlen); /* also set user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
if(userdir != fullname) {
BLI_strncpy(userdir, fullname, maxlen); /* also set user pref to show %TEMP%. /tmp/ is just plain confusing for Windows users. */
}
#endif
}
}
void BLI_init_temporary_dir(char *userdir)
{
BLI_where_is_temp(btempdir, FILE_MAX, userdir);
}
const char *BLI_temporary_dir(void)
{
return btempdir;
}
void BLI_system_temporary_dir(char *dir)
{
BLI_where_is_temp(dir, FILE_MAX, NULL);
}
#ifdef WITH_ICONV
void BLI_string_to_utf8(char *original, char *utf_8, const char *code)

@ -88,10 +88,9 @@
#include "DNA_listBase.h"
#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_linklist.h"
#include "BLI_storage.h"
#include "BLI_storage_types.h"
#include "BLI_string.h"
#include "BKE_utildefines.h"
@ -104,7 +103,7 @@ static struct ListBase dirbase_={NULL, NULL};
static struct ListBase *dirbase = &dirbase_;
/* can return NULL when the size is not big enough */
char *BLI_getwdN(char *dir, const int maxncpy)
char *BLI_current_working_dir(char *dir, const int maxncpy)
{
const char *pwd= getenv("PWD");
if (pwd){
@ -116,7 +115,7 @@ char *BLI_getwdN(char *dir, const int maxncpy)
}
int BLI_compare(struct direntry *entry1, struct direntry *entry2)
static int bli_compare(struct direntry *entry1, struct direntry *entry2)
{
/* type is equal to stat.st_mode */
@ -143,7 +142,7 @@ int BLI_compare(struct direntry *entry1, struct direntry *entry2)
}
double BLI_diskfree(const char *dir)
double BLI_dir_free_space(const char *dir)
{
#ifdef WIN32
DWORD sectorspc, bytesps, freec, clusters;
@ -198,7 +197,7 @@ double BLI_diskfree(const char *dir)
#endif
}
void BLI_builddir(const char *dirname, const char *relname)
static void bli_builddir(const char *dirname, const char *relname)
{
struct dirent *fname;
struct dirlink *dlink;
@ -273,7 +272,7 @@ void BLI_builddir(const char *dirname, const char *relname)
}
BLI_freelist(dirbase);
if (files) qsort(files, actnum, sizeof(struct direntry), (int (*)(const void *,const void*))BLI_compare);
if (files) qsort(files, actnum, sizeof(struct direntry), (int (*)(const void *,const void*))bli_compare);
} else {
printf("%s empty directory\n",dirname);
}
@ -284,7 +283,7 @@ void BLI_builddir(const char *dirname, const char *relname)
}
}
void BLI_adddirstrings(void)
static void bli_adddirstrings(void)
{
char datum[100];
char buf[512];
@ -392,7 +391,7 @@ void BLI_adddirstrings(void)
}
}
unsigned int BLI_getdir(const char *dirname, struct direntry **filelist)
unsigned int BLI_dir_contents(const char *dirname, struct direntry **filelist)
{
// reset global variables
// memory stored in files is free()'d in
@ -401,8 +400,8 @@ unsigned int BLI_getdir(const char *dirname, struct direntry **filelist)
actnum = totnum = 0;
files = NULL;
BLI_builddir(dirname,"");
BLI_adddirstrings();
bli_builddir(dirname,"");
bli_adddirstrings();
if (files) {
*(filelist) = files;
@ -416,7 +415,7 @@ unsigned int BLI_getdir(const char *dirname, struct direntry **filelist)
}
size_t BLI_filesize(int file)
size_t BLI_file_descriptor_size(int file)
{
struct stat buf;
@ -425,20 +424,20 @@ size_t BLI_filesize(int file)
return (buf.st_size);
}
size_t BLI_filepathsize(const char *path)
size_t BLI_file_size(const char *path)
{
int size, file = open(path, O_BINARY|O_RDONLY);
if (file == -1)
return -1;
size = BLI_filesize(file);
size = BLI_file_descriptor_size(file);
close(file);
return size;
}
int BLI_exist(const char *name)
int BLI_exists(const char *name)
{
#if defined(WIN32) && !defined(__MINGW32__)
struct _stat64i32 st;
@ -471,10 +470,10 @@ int BLI_exist(const char *name)
/* would be better in fileops.c except that it needs stat.h so add here */
int BLI_is_dir(const char *file)
{
return S_ISDIR(BLI_exist(file));
return S_ISDIR(BLI_exists(file));
}
LinkNode *BLI_read_file_as_lines(const char *name)
LinkNode *BLI_file_read_as_lines(const char *name)
{
FILE *fp= fopen(name, "r");
LinkNode *lines= NULL;
@ -515,7 +514,7 @@ LinkNode *BLI_read_file_as_lines(const char *name)
return lines;
}
void BLI_free_file_lines(LinkNode *lines)
void BLI_file_free_lines(LinkNode *lines)
{
BLI_linklist_free(lines, (void(*)(void*)) MEM_freeN);
}

@ -34,7 +34,6 @@
#include <stddef.h>
#include "BLI_storage.h" /* _LARGEFILE_SOURCE */
#include <stdlib.h>
#include <string.h>
@ -43,11 +42,12 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_fileops.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_genfile.h"
#include "DNA_sdna_types.h"

@ -8727,7 +8727,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
for (wo = main->world.first; wo; wo= wo->id.next) {
/* Migrate to Bullet for games, except for the NaN versions */
/* People can still explicitely choose for Sumo (after 2.42 is out) */
/* People can still explicitly choose for Sumo (after 2.42 is out) */
if(main->versionfile > 225)
wo->physicsEngine = WOPHY_BULLET;
if(WO_AODIST == wo->aomode)

@ -111,7 +111,7 @@ BlendFileData *BLO_read_runtime(const char *path, ReportList *reports)
goto cleanup;
}
actualsize= BLI_filesize(fd);
actualsize= BLI_file_descriptor_size(fd);
lseek(fd, -12, SEEK_END);

@ -2737,7 +2737,7 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
/* first write compressed to separate @.gz */
BLI_snprintf(gzname, sizeof(gzname), "%s@.gz", filepath);
ret = BLI_gzip(tempname, gzname);
ret = BLI_file_gzip(tempname, gzname);
if(0==ret) {
/* now rename to real file name, and delete temp @ file too */

@ -110,7 +110,7 @@ void ImagesExporter::operator()(Material *ma, Object *ob)
// make dest directory if it doesn't exist
BLI_make_existing_file(abs);
if (BLI_copy_fileops(src, abs) != 0) {
if (BLI_copy(src, abs) != 0) {
fprintf(stderr, "Cannot copy image to file's directory. \n");
}
}

@ -40,9 +40,8 @@ extern "C"
#include "BKE_context.h"
/* make dummy file */
#include "BLI_storage.h"
#include "BLI_path_util.h"
#include "BLI_fileops.h"
#include "BLI_path_util.h"
int collada_import(bContext *C, const char *filepath)
{
@ -60,9 +59,9 @@ extern "C"
export_settings.filepath = (char *)filepath;
/* annoying, collada crashes if file cant be created! [#27162] */
if(!BLI_exist(filepath)) {
if(!BLI_exists(filepath)) {
BLI_make_existing_file(filepath); /* makes the dir if its not there */
if(BLI_touch(filepath) == 0) {
if(BLI_file_touch(filepath) == 0) {
return 0;
}
}

@ -118,7 +118,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
PropertyRNA *nameprop= RNA_struct_name_property(ptr.type);
if (nameprop) {
/* this gets a string which will need to be freed */
structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0);
structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL);
free_structname= 1;
}
else

File diff suppressed because it is too large Load Diff

@ -1593,17 +1593,18 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
PropertyType type;
char *buf= NULL;
int buf_len;
type= RNA_property_type(but->rnaprop);
if(type == PROP_STRING) {
/* RNA string */
buf= RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen);
buf= RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len);
}
else if(type == PROP_POINTER) {
/* RNA pointer */
PointerRNA ptr= RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
buf= RNA_struct_name_get_alloc(&ptr, str, maxlen);
buf= RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len);
}
if(!buf) {
@ -1611,7 +1612,7 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
}
else if(buf && buf != str) {
/* string was too long, we have to truncate */
BLI_strncpy(str, buf, maxlen);
memcpy(str, buf, MIN2(maxlen, buf_len+1));
MEM_freeN(buf);
}
}

@ -2199,15 +2199,11 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
/* always set */
but->modifier_key = 0;
if(event->shift)
but->modifier_key |= KM_SHIFT;
if(event->alt)
but->modifier_key |= KM_ALT;
if(event->ctrl)
but->modifier_key |= KM_CTRL;
if(event->oskey)
but->modifier_key |= KM_OSKEY;
if(event->shift) but->modifier_key |= KM_SHIFT;
if(event->alt) but->modifier_key |= KM_ALT;
if(event->ctrl) but->modifier_key |= KM_CTRL;
if(event->oskey) but->modifier_key |= KM_OSKEY;
ui_check_but(but);
ED_region_tag_redraw(data->region);
@ -3673,7 +3669,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
if(sel!= -1) {
/* ok, we move a point */
/* deselect all if this one is deselect. except if we hold shift */
if(event->shift==0) {
if(event->shift == FALSE) {
for(a=0; a<cuma->totpoint; a++)
cmp[a].flag &= ~SELECT;
cmp[sel].flag |= SELECT;
@ -3712,7 +3708,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
if(!data->dragchange) {
/* deselect all, select one */
if(event->shift==0) {
if(event->shift == FALSE) {
for(a=0; a<cuma->totpoint; a++)
cmp[a].flag &= ~SELECT;
cmp[data->dragsel].flag |= SELECT;
@ -4491,7 +4487,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
ui_but_drop (C, event, but, data);
}
/* handle keyframing */
else if(event->type == IKEY && !ELEM3(1, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
else if(event->type == IKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
if(event->alt)
ui_but_anim_delete_keyframe(C);
else
@ -4502,7 +4498,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
return WM_UI_HANDLER_BREAK;
}
/* handle drivers */
else if(event->type == DKEY && !ELEM3(1, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
else if(event->type == DKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
if(event->alt)
ui_but_anim_remove_driver(C);
else
@ -4513,7 +4509,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
return WM_UI_HANDLER_BREAK;
}
/* handle keyingsets */
else if(event->type == KKEY && !ELEM3(1, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
else if(event->type == KKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
if(event->alt)
ui_but_anim_remove_keyingset(C);
else
@ -5983,9 +5979,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
case ZKEY:
{
if( (event->val == KM_PRESS) &&
(event->shift == FALSE) &&
(event->ctrl == FALSE) &&
(event->oskey == FALSE)
(event->shift == FALSE) &&
(event->ctrl == FALSE) &&
(event->oskey == FALSE)
) {
for(but= block->buttons.first; but; but= but->next) {

@ -47,7 +47,6 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "DNA_brush_types.h"
@ -609,11 +608,11 @@ static void init_iconfile_list(struct ListBase *list)
if(icondir==NULL)
return;
/* since BLI_getdir changes the current working directory, restore it
/* since BLI_dir_contents changes the current working directory, restore it
back to old value afterwards */
if(!BLI_getwdN(olddir, sizeof(olddir)))
if(!BLI_current_working_dir(olddir, sizeof(olddir)))
restoredir = 0;
totfile = BLI_getdir(icondir, &dir);
totfile = BLI_dir_contents(icondir, &dir);
if (restoredir && !chdir(olddir)) {} /* fix warning about checking return value */
for(i=0; i<totfile; i++) {
@ -662,7 +661,7 @@ static void init_iconfile_list(struct ListBase *list)
}
}
/* free temporary direntry structure that's been created by BLI_getdir() */
/* free temporary direntry structure that's been created by BLI_dir_contents() */
i= totfile-1;
for(; i>=0; i--){

@ -1221,7 +1221,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s
iconid= ui_id_icon_get((bContext*)C, id, 1);
}
else {
name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */
iconid = 0;
}

@ -1042,7 +1042,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
inside= 1;
if(inside && event->val==KM_PRESS) {
if(event->type == AKEY && !ELEM4(1, event->ctrl, event->oskey, event->shift, event->alt)) {
if(event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) {
if(pa->flag & PNL_CLOSEDY) {
if((block->maxy <= my) && (block->maxy+PNL_HEADER >= my))

@ -2085,7 +2085,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
if(icon == ICON_NONE || icon == ICON_DOT)
icon= 0;
namebuf= RNA_struct_name_get_alloc(itemptr, NULL, 0);
namebuf= RNA_struct_name_get_alloc(itemptr, NULL, 0, NULL);
name= (namebuf)? namebuf: "";
/* hardcoded types */
@ -2270,7 +2270,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
if(found) {
/* create button */
name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL);
icon= list_item_icon_get(C, &itemptr, rnaicon, 0);
uiItemL(row, (name)? name: "", icon);

@ -1127,7 +1127,7 @@ void init_userdef_do_versions(void)
}
if(U.mixbufsize==0) U.mixbufsize= 2048;
if (strcmp(U.tempdir, "/") == 0) {
BLI_where_is_temp(U.tempdir, sizeof(U.tempdir), FALSE);
BLI_system_temporary_dir(U.tempdir);
}
if (U.autokey_mode == 0) {
/* 'add/replace' but not on */

@ -53,6 +53,7 @@
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLI_math_vector.h"
#include "BLI_linklist.h"
#include "ED_object.h"
#include "ED_mesh.h"

@ -3701,7 +3701,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event)
RNA_collection_add(op->ptr, "stroke", &itemptr);
RNA_float_set_array(&itemptr, "mouse", mouse);
RNA_boolean_set(&itemptr, "pen_flip", event->shift != 0); // XXX hardcoded
RNA_boolean_set(&itemptr, "pen_flip", event->shift != FALSE); // XXX hardcoded
/* apply */
brush_edit_apply(C, op, &itemptr);

@ -50,7 +50,6 @@
#include "DNA_object_fluidsim.h"
#include "BLI_blenlib.h"
#include "BLI_fileops.h"
#include "BLI_threads.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
@ -833,7 +832,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss)
curFrame++;
if((exists = BLI_exist(targetFile)))
if((exists = BLI_exists(targetFile)))
{
BLI_delete(targetFile, 0, 0);
BLI_delete(targetFileVel, 0, 0);

@ -47,7 +47,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_animsys.h"

@ -925,7 +925,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
if(ptr->data) {
icon= RNA_struct_ui_icon(ptr->type);
name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf));
name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL);
if(name) {
if(!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene)

@ -39,7 +39,6 @@
#include "BLI_fileops.h"
#include "BLI_path_util.h"
#include "BLI_storage.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@ -169,7 +168,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
if(!prop)
return OPERATOR_CANCELLED;
str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0);
str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL);
/* useful yet irritating feature, Shift+Click to open the file
* Alt+Click to browse a folder in the OS's browser */

@ -37,7 +37,6 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_dynstr.h"
#include "BLI_storage_types.h"
#ifdef WIN32
#include "BLI_winstuff.h"
#endif

@ -39,7 +39,6 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_storage_types.h"
#ifdef WIN32
#include "BLI_winstuff.h"
#endif
@ -749,7 +748,7 @@ int file_exec(bContext *C, wmOperator *exec_op)
file_sfile_to_operator(op, sfile, filepath);
if (BLI_exist(sfile->params->dir))
if (BLI_exists(sfile->params->dir))
fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, 0, 1);
BLI_make_file_string(G.main->name, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
@ -1042,7 +1041,7 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
}
/* create the file */
BLI_recurdir_fileops(path);
BLI_dir_create_recursive(path);
if (!BLI_exists(path)) {
BKE_report(op->reports,RPT_ERROR, "Couldn't create new folder");
@ -1136,7 +1135,7 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
file_expand_directory(C);
if (!BLI_exists(sfile->params->dir)) {
BLI_recurdir_fileops(sfile->params->dir);
BLI_dir_create_recursive(sfile->params->dir);
}
/* special case, user may have pasted a fulepath into the directory */

@ -48,7 +48,6 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_storage_types.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
@ -825,10 +824,10 @@ static void filelist_read_dir(struct FileList* filelist)
filelist->fidx = NULL;
filelist->filelist = NULL;
BLI_getwdN(wdir, sizeof(wdir)); /* backup cwd to restore after */
BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */
BLI_cleanup_dir(G.main->name, filelist->dir);
filelist->numfiles = BLI_getdir(filelist->dir, &(filelist->filelist));
filelist->numfiles = BLI_dir_contents(filelist->dir, &(filelist->filelist));
if(!chdir(wdir)) {} /* fix warning about not checking return value */
filelist_setfiletypes(filelist);

@ -64,8 +64,6 @@
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_path_util.h"
#include "BLI_storage_types.h"
#include "BLI_dynstr.h"
#include "BLI_utildefines.h"

@ -278,7 +278,7 @@ void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename)
if (line[len-1] == '\n') {
line[len-1] = '\0';
}
if (BLI_exist(line)) {
if (BLI_exists(line)) {
fsmenu_insert_entry(fsmenu, category, line, 0, 1);
}
}

@ -46,7 +46,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"

@ -143,7 +143,7 @@ static int space_image_file_exists_poll(bContext *C)
if(ibuf) {
BLI_strncpy(name, ibuf->name, FILE_MAX);
BLI_path_abs(name, bmain->name);
poll= (BLI_exists(name) && BLI_is_writable(name));
poll= (BLI_exists(name) && BLI_file_is_writable(name));
}
ED_space_image_release_buffer(sima, lock);
@ -1223,7 +1223,7 @@ static int save_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
save_image_options_from_op(&simopts, op);
if (BLI_exists(simopts.filepath) && BLI_is_writable(simopts.filepath)) {
if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) {
save_image_doit(C, sima, op, &simopts, FALSE);
}
else {

@ -49,7 +49,6 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
@ -66,11 +65,6 @@
#include "BKE_texture.h"
#include "BKE_report.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_storage_types.h"
#include "RE_pipeline.h"
#include "IMB_imbuf_types.h"

@ -1021,7 +1021,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
/* tsenext= TREESTORE(temnext); */ /* UNUSED */
nextptr= &temnext->rnaptr;
name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf));
name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL);
if(name) {
/* if possible, use name as a key in the path */

@ -972,7 +972,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
}
else if(type == TSE_RNA_STRUCT) {
/* struct */
te->name= RNA_struct_name_get_alloc(ptr, NULL, 0);
te->name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
if(te->name)
te->flag |= TE_FREE_NAME;

@ -44,7 +44,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "DNA_scene_types.h"

@ -45,7 +45,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_storage_types.h"
#include "BLI_utildefines.h"
#include "BLI_threads.h"
@ -883,7 +882,7 @@ static void UNUSED_FUNCTION(touch_seq_files)(Scene *scene)
if(seq->type==SEQ_MOVIE) {
if(seq->strip && seq->strip->stripdata) {
BLI_make_file_string(G.main->name, str, seq->strip->dir, seq->strip->stripdata->name);
BLI_touch(seq->name);
BLI_file_touch(seq->name);
}
}

@ -40,7 +40,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_path_util.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"

@ -1547,10 +1547,11 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
{
if (kmi->propvalue == TFM_MODAL_SNAP_INV_ON && kmi->val == KM_PRESS)
{
if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) && event->ctrl) ||
(ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) ||
(ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) && event->alt) ||
(kmi->type == OSKEY && event->oskey)) {
if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) && event->ctrl) ||
(ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) ||
(ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) && event->alt) ||
((kmi->type == OSKEY) && event->oskey) )
{
t->modifiers |= MOD_SNAP_INVERT;
}
break;

@ -67,9 +67,6 @@
# include <dirent.h>
#endif
#include "BLI_blenlib.h" /* BLI_remlink BLI_filesize BLI_addtail
BLI_countlist BLI_stringdec */
#include "imbuf.h"
#include "AVI_avi.h"

@ -546,7 +546,7 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig
{
ExrHandle *data= (ExrHandle *)handle;
if(BLI_exists(filename) && BLI_filepathsize(filename)>32) { /* 32 is arbitrary, but zero length files crashes exr */
if(BLI_exists(filename) && BLI_file_size(filename)>32) { /* 32 is arbitrary, but zero length files crashes exr */
data->ifile = new InputFile(filename);
if(data->ifile) {
Box2i dw = data->ifile->header().dataWindow();

@ -88,7 +88,7 @@ ImBuf *IMB_loadifffile(int file, int flags)
if(file == -1) return NULL;
size= BLI_filesize(file);
size= BLI_file_descriptor_size(file);
mem= mmap(NULL, size, PROT_READ, MAP_SHARED, file, 0);
if(mem==(unsigned char*)-1) {
@ -175,7 +175,7 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int
if(file == -1) return;
size= BLI_filesize(file);
size= BLI_file_descriptor_size(file);
mem= mmap(NULL, size, PROT_READ, MAP_SHARED, file, 0);
if(mem==(unsigned char*)-1) {

@ -237,10 +237,10 @@ void IMB_thumb_makedirs(void)
{
char tpath[FILE_MAX];
if (get_thumb_dir(tpath, THB_NORMAL)) {
BLI_recurdir_fileops(tpath);
BLI_dir_create_recursive(tpath);
}
if (get_thumb_dir(tpath, THB_FAIL)) {
BLI_recurdir_fileops(tpath);
BLI_dir_create_recursive(tpath);
}
}
@ -277,7 +277,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
/* exception, skip images over 100mb */
if(source == THB_SOURCE_IMAGE) {
const size_t size= BLI_filepathsize(path);
const size_t size= BLI_file_size(path);
if(size != -1 && size > THUMB_SIZE_MAX) {
// printf("file too big: %d, skipping %s\n", (int)size, path);
return NULL;

@ -650,7 +650,7 @@ PropertyRNA *RNA_struct_type_find_property(StructRNA *srna, const char *identifi
FunctionRNA *RNA_struct_find_function(PointerRNA *ptr, const char *identifier);
const struct ListBase *RNA_struct_type_functions(StructRNA *srna);
char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen);
char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len);
/* Properties
*
@ -757,7 +757,7 @@ void RNA_property_float_get_default_array(PointerRNA *ptr, PropertyRNA *prop, fl
float RNA_property_float_get_default_index(PointerRNA *ptr, PropertyRNA *prop, int index);
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value);
char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen);
char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len);
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value);
int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop);
void RNA_property_string_get_default(PointerRNA *ptr, PropertyRNA *prop, char *value);
@ -825,20 +825,6 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path,
char *RNA_path_from_ID_to_struct(PointerRNA *ptr);
char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop);
#if 0
/* Dependency
*
* Experimental code that will generate callbacks for each dependency
* between ID types. This may end up being useful for UI
* and evaluation code that needs to know such dependencies for correct
* redraws and re-evaluations. */
typedef void (*PropDependencyCallback)(void *udata, PointerRNA *from, PointerRNA *to);
void RNA_test_dependencies_cb(void *udata, PointerRNA *from, PointerRNA *to);
void RNA_generate_dependencies(PointerRNA *mainptr, void *udata, PropDependencyCallback cb);
#endif
/* Quick name based property access
*
* These are just an easier way to access property values without having to

@ -748,12 +748,12 @@ void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
srna->blender_type= blender_type;
}
char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen)
char *RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
{
PropertyRNA *nameprop;
if(ptr->data && (nameprop = RNA_struct_name_property(ptr->type)))
return RNA_property_string_get_alloc(ptr, nameprop, fixedbuf, fixedlen);
return RNA_property_string_get_alloc(ptr, nameprop, fixedbuf, fixedlen, r_len);
return NULL;
}
@ -2276,7 +2276,8 @@ void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
strcpy(value, sprop->defaultvalue);
}
char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen)
char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop,
char *fixedbuf, int fixedlen, int *r_len)
{
char *buf;
int length;
@ -2301,6 +2302,10 @@ char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fi
BLI_assert(buf[length] == '\0');
#endif
if (r_len) {
*r_len= length;
}
return buf;
}
@ -2836,15 +2841,17 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co
PropertyRNA *nameprop;
char name[256], *nameptr;
int found= 0;
int keylen= strlen(key);
int namelen;
RNA_property_collection_begin(ptr, prop, &iter);
for(; iter.valid; RNA_property_collection_next(&iter)) {
if(iter.ptr.data && iter.ptr.type->nameproperty) {
nameprop= iter.ptr.type->nameproperty;
nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name));
nameptr= RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name), &namelen);
if(strcmp(nameptr, key) == 0) {
if((keylen == namelen) && (strcmp(nameptr, key) == 0)) {
*r_ptr= iter.ptr;
found= 1;
}
@ -4254,7 +4261,7 @@ char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, in
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
if(prop) {
return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen);
return RNA_property_string_get_alloc(ptr, prop, fixedbuf, fixedlen, NULL); /* TODO, pass length */
}
else {
printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name);
@ -5442,7 +5449,7 @@ int RNA_property_copy(PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, i
}
case PROP_STRING:
{
char *value= RNA_property_string_get_alloc(fromptr, prop, NULL, 0);
char *value= RNA_property_string_get_alloc(fromptr, prop, NULL, 0, NULL);
RNA_property_string_set(ptr, prop, value);
MEM_freeN(value);
return 1;

@ -40,7 +40,6 @@
#include <stddef.h>
#include "BLI_blenlib.h"
#include "BKE_armature.h"
void rna_EditBone_align_roll(EditBone *ebo, float no[3])

@ -42,8 +42,6 @@
#include <stddef.h>
#include "BLI_blenlib.h"
#include "BKE_animsys.h"
#include "BKE_fcurve.h"

@ -96,7 +96,7 @@ static int fluidsim_find_lastframe(FluidsimSettings *fss)
do {
BLI_strncpy(targetFile, targetDir, sizeof(targetFile));
BLI_path_frame(targetFile, curFrame++, 0);
} while(BLI_exist(targetFile));
} while(BLI_exists(targetFile));
return curFrame - 1;
}

@ -40,8 +40,6 @@
#ifdef RNA_RUNTIME
#include "BLI_path_util.h"
static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
{
bGPDlayer *gpl= (bGPDlayer *)ptr->data;

@ -98,8 +98,6 @@ static EnumPropertyItem empty_vortex_shape_items[] = {
#include "BKE_pointcache.h"
#include "BKE_depsgraph.h"
#include "BLI_blenlib.h"
#include "ED_object.h"
static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)

@ -120,7 +120,6 @@ EnumPropertyItem part_hair_ren_as_items[] = {
#ifdef RNA_RUNTIME
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BKE_context.h"
#include "BKE_cloth.h"

@ -36,6 +36,7 @@
#include "rna_internal.h"
#include "RE_engine.h"
#include "RE_pipeline.h"
#include "BKE_utildefines.h"

@ -177,7 +177,6 @@ EnumPropertyItem image_color_mode_items[] ={
#include "BLI_threads.h"
#include "BLI_editVert.h"
#include "BLI_blenlib.h"
#include "BKE_context.h"
#include "BKE_global.h"
@ -202,7 +201,7 @@ EnumPropertyItem image_color_mode_items[] ={
#include "ED_mesh.h"
#include "ED_keyframing.h"
#include "RE_pipeline.h"
#include "RE_engine.h"
static int rna_Scene_object_bases_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)
{

@ -295,8 +295,7 @@ static void rna_userdef_addon_remove(bAddon *bext)
static void rna_userdef_temp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
{
extern char btempdir[];
BLI_where_is_temp(btempdir, FILE_MAX, 1);
BLI_init_temporary_dir(U.tempdir);
}
static void rna_userdef_text_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))

@ -38,6 +38,7 @@
#include "BLI_math.h"
#include "BLI_array.h"
#include "BLI_smallhash.h"
#include "BLI_linklist.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_modifier.h"

@ -105,7 +105,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
/* elubie: changed this to default to the same dir as the render output
to prevent saving to C:\ on Windows */
BLI_strncpy(fss->surfdataPath, btempdir, FILE_MAX);
BLI_strncpy(fss->surfdataPath, BLI_temporary_dir(), FILE_MAX);
// first init of bounding box
// no bounding box needed

@ -1320,7 +1320,7 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy)
if ((xy < 1) || (xy > 3)) xy = 3;
// XXX The YVV macro defined below explicitely expects sources of at least 3x3 pixels,
// XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels,
// so just skiping blur along faulty direction if src's def is below that limit!
if (src->x < 3) xy &= ~(int) 1;
if (src->y < 3) xy &= ~(int) 2;
@ -1346,7 +1346,7 @@ void IIR_gauss(CompBuf* src, float sigma, int chan, int xy)
// it seems to work, not entirely sure if it is actually totally correct,
// Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark),
// found one other implementation by Cristoph Lampert,
// but neither seem to be quite the same, result seems to be ok sofar anyway.
// but neither seem to be quite the same, result seems to be ok so far anyway.
// Extra scale factor here to not have to do it in filter,
// though maybe this had something to with the precision errors
sc = cf[0]/((1.0 + cf[1] - cf[2] + cf[3])*(1.0 - cf[1] - cf[2] - cf[3])*(1.0 + cf[2] + (cf[1] - cf[3])*cf[3]));

@ -86,8 +86,9 @@ static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
getpix(tmp, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, col);
/* mix img and transformed tmp */
for(j= 0; j < 4; ++j)
img->rect[p + j]= AVG2(img->rect[p + j], col[j]);
for(j= 0; j < 4; ++j) {
img->rect[p + j]= 0.5f * (img->rect[p + j] + col[j]);
}
}
}

@ -36,8 +36,6 @@
#ifndef BPY_EXTERN_H
#define BPY_EXTERN_H
extern char bprogname[]; /* holds a copy of argv[0], from creator.c */
struct Text; /* defined in DNA_text_types.h */
struct ID; /* DNA_ID.h */
struct Object; /* DNA_object_types.h */

@ -67,9 +67,9 @@ PyObject *BPy_IDGroup_WrapData( ID *id, IDProperty *prop )
switch ( prop->type ) {
case IDP_STRING:
#ifdef USE_STRING_COERCE
return PyC_UnicodeFromByte(IDP_Array(prop));
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len);
#else
return PyUnicode_FromString(IDP_Array(prop));
return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len);
#endif
case IDP_INT:
return PyLong_FromLong( (long)prop->data.val );
@ -485,9 +485,9 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
switch (prop->type) {
case IDP_STRING:
#ifdef USE_STRING_COERCE
return PyC_UnicodeFromByte(IDP_Array(prop));
return PyC_UnicodeFromByteAndSize(IDP_Array(prop), prop->len);
#else
return PyUnicode_FromString(IDP_Array(prop));
return PyUnicode_FromStringAndSize(IDP_Array(prop), prop->len);
#endif
break;
case IDP_FLOAT:

@ -386,9 +386,9 @@ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)
}
}
PyObject *PyC_UnicodeFromByte(const char *str)
PyObject *PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size)
{
PyObject *result= PyUnicode_FromString(str);
PyObject *result= PyUnicode_FromStringAndSize(str, size);
if (result) {
/* 99% of the time this is enough but we better support non unicode
* chars since blender doesnt limit this */
@ -397,11 +397,16 @@ PyObject *PyC_UnicodeFromByte(const char *str)
else {
PyErr_Clear();
/* this means paths will always be accessible once converted, on all OS's */
result= PyUnicode_DecodeFSDefault(str);
result= PyUnicode_DecodeFSDefaultAndSize(str, size);
return result;
}
}
PyObject *PyC_UnicodeFromByte(const char *str)
{
return PyC_UnicodeFromByteAndSize(str, strlen(str));
}
/*****************************************************************************
* Description: This function creates a new Python dictionary object.
* note: dict is owned by sys.modules["__main__"] module, reference is borrowed

@ -40,8 +40,9 @@ void PyC_FileAndNum_Safe(const char **filename, int *lineno); /* checks python
int PyC_AsArray(void *array, PyObject *value, const int length, const PyTypeObject *type, const short is_double, const char *error_prefix);
/* follow http://www.python.org/dev/peps/pep-0383/ */
PyObject * PyC_UnicodeFromByte(const char *str);
const char * PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce); /* coerce must be NULL */
PyObject * PyC_UnicodeFromByte(const char *str);
PyObject * PyC_UnicodeFromByteAndSize(const char *str, Py_ssize_t size);
const char * PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce); /* coerce must be NULL */
/* name namespace function for bpy & bge */
PyObject * PyC_DefaultNameSpace(const char *filename);

@ -93,8 +93,6 @@ static PyStructSequence_Desc app_info_desc= {
static PyObject *make_app_info(void)
{
extern char bprogname[]; /* argv[0] from creator.c */
PyObject *app_info;
int pos= 0;
@ -118,7 +116,7 @@ static PyObject *make_app_info(void)
SetStrItem("");
#endif
SetStrItem(STRINGIFY(BLENDER_VERSION_CYCLE));
SetStrItem(bprogname);
SetStrItem(BLI_program_path());
SetObjItem(PyBool_FromLong(G.background));
/* build info */
@ -200,8 +198,7 @@ static int bpy_app_debug_value_set(PyObject *UNUSED(self), PyObject *value, void
static PyObject *bpy_app_tempdir_get(PyObject *UNUSED(self), void *UNUSED(closure))
{
extern char btempdir[];
return PyC_UnicodeFromByte(btempdir);
return PyC_UnicodeFromByte(BLI_temporary_dir());
}
static PyObject *bpy_app_driver_dict_get(PyObject *UNUSED(self), void *UNUSED(closure))

@ -193,9 +193,9 @@ void BPY_python_start(int argc, const char **argv)
PyThreadState *py_tstate= NULL;
/* not essential but nice to set our name */
static wchar_t bprogname_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */
BLI_strncpy_wchar_from_utf8(bprogname_wchar, bprogname, sizeof(bprogname_wchar) / sizeof(wchar_t));
Py_SetProgramName(bprogname_wchar);
static wchar_t program_path_wchar[FILE_MAXDIR+FILE_MAXFILE]; /* python holds a reference */
BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t));
Py_SetProgramName(program_path_wchar);
/* must run before python initializes */
PyImport_ExtendInittab(bpy_internal_modules);
@ -203,9 +203,9 @@ void BPY_python_start(int argc, const char **argv)
/* allow to use our own included python */
PyC_SetHomePath(BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL));
/* Python 3.2 now looks for '2.58/python/include/python3.2d/pyconfig.h' to parse
* from the 'sysconfig' module which is used by 'site', so for now disable site.
* alternatively we could copy the file. */
/* Python 3.2 now looks for '2.xx/python/include/python3.2d/pyconfig.h' to
* parse from the 'sysconfig' module which is used by 'site',
* so for now disable site. alternatively we could copy the file. */
Py_NoSiteFlag= 1;
Py_Initialize();
@ -215,8 +215,11 @@ void BPY_python_start(int argc, const char **argv)
{
int i;
PyObject *py_argv= PyList_New(argc);
for (i=0; i<argc; i++)
PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i])); /* should fix bug #20021 - utf path name problems, by replacing PyUnicode_FromString */
for (i=0; i<argc; i++) {
/* should fix bug #20021 - utf path name problems, by replacing
* PyUnicode_FromString, with this one */
PyList_SET_ITEM(py_argv, i, PyC_UnicodeFromByte(argv[i]));
}
PySys_SetObject("argv", py_argv);
Py_DECREF(py_argv);
@ -671,7 +674,7 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
#ifdef WITH_PYTHON_MODULE
#include "BLI_storage.h"
#include "BLI_fileops.h"
/* TODO, reloading the module isnt functional at the moment. */
static void bpy_module_free(void *mod);

@ -810,7 +810,7 @@ static PyObject *pyrna_struct_str(BPy_StructRNA *self)
}
/* print name if available */
name= RNA_struct_name_get_alloc(&self->ptr, NULL, FALSE);
name= RNA_struct_name_get_alloc(&self->ptr, NULL, 0, NULL);
if (name) {
ret= PyUnicode_FromFormat("<bpy_struct, %.200s(\"%.200s\")>",
RNA_struct_identifier(self->ptr.type),
@ -901,7 +901,7 @@ static PyObject *pyrna_prop_str(BPy_PropertyRNA *self)
/* if a pointer, try to print name of pointer target too */
if (RNA_property_type(self->prop) == PROP_POINTER) {
ptr= RNA_property_pointer_get(&self->ptr, self->prop);
name= RNA_struct_name_get_alloc(&ptr, NULL, FALSE);
name= RNA_struct_name_get_alloc(&ptr, NULL, 0, NULL);
if (name) {
ret= PyUnicode_FromFormat("<bpy_%.200s, %.200s.%.200s(\"%.200s\")>",
@ -1257,14 +1257,22 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
ret= PyUnicode_FromString(enum_item->identifier);
}
else {
const char *ptr_name= RNA_struct_name_get_alloc(ptr, NULL, FALSE);
const char *ptr_name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
/* prefer not fail silently incase of api errors, maybe disable it later */
printf("RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'\n", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop));
printf("RNA Warning: Current value \"%d\" "
"matches no enum in '%s', '%s', '%s'\n",
val, RNA_struct_identifier(ptr->type),
ptr_name, RNA_property_identifier(prop));
#if 0 // gives python decoding errors while generating docs :(
char error_str[256];
BLI_snprintf(error_str, sizeof(error_str), "RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop));
BLI_snprintf(error_str, sizeof(error_str),
"RNA Warning: Current value \"%d\" "
"matches no enum in '%s', '%s', '%s'",
val, RNA_struct_identifier(ptr->type),
ptr_name, RNA_property_identifier(prop));
PyErr_Warn(PyExc_RuntimeWarning, error_str);
#endif
@ -1311,19 +1319,20 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
{
int subtype= RNA_property_subtype(prop);
const char *buf;
int buf_len;
char buf_fixed[32];
buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed));
buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed), &buf_len);
#ifdef USE_STRING_COERCE
/* only file paths get special treatment, they may contain non utf-8 chars */
if (ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) {
ret= PyC_UnicodeFromByte(buf);
ret= PyC_UnicodeFromByteAndSize(buf, buf_len);
}
else {
ret= PyUnicode_FromString(buf);
ret= PyUnicode_FromStringAndSize(buf, buf_len);
}
#else // USE_STRING_COERCE
ret= PyUnicode_FromString(buf);
ret= PyUnicode_FromStringAndSize(buf, buf_len);
#endif // USE_STRING_COERCE
if (buf_fixed != buf) {
MEM_freeN((void *)buf);
@ -3127,14 +3136,15 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
* Collect RNA attributes
*/
char name[256], *nameptr;
int namelen;
iterprop= RNA_struct_iterator_property(ptr->type);
RNA_PROP_BEGIN(ptr, itemptr, iterprop) {
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
if (nameptr) {
pystring= PyUnicode_FromString(nameptr);
pystring= PyUnicode_FromStringAndSize(nameptr, namelen);
PyList_Append(list, pystring);
Py_DECREF(pystring);
@ -3716,13 +3726,14 @@ static PyObject *pyrna_prop_collection_keys(BPy_PropertyRNA *self)
PyObject *ret= PyList_New(0);
PyObject *item;
char name[256], *nameptr;
int namelen;
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
if (nameptr) {
/* add to python list */
item= PyUnicode_FromString(nameptr);
item= PyUnicode_FromStringAndSize(nameptr, namelen);
PyList_Append(ret, item);
Py_DECREF(item);
/* done */
@ -3751,15 +3762,16 @@ static PyObject *pyrna_prop_collection_items(BPy_PropertyRNA *self)
PyObject *ret= PyList_New(0);
PyObject *item;
char name[256], *nameptr;
int namelen;
int i= 0;
RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
if (itemptr.data) {
/* add to python list */
item= PyTuple_New(2);
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name));
nameptr= RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
if (nameptr) {
PyTuple_SET_ITEM(item, 0, PyUnicode_FromString(nameptr));
PyTuple_SET_ITEM(item, 0, PyUnicode_FromStringAndSize(nameptr, namelen));
if (name != nameptr)
MEM_freeN(nameptr);
}

@ -56,6 +56,7 @@ set(SRC
intern/raytrace/rayobject_vbvh.cpp
intern/source/convertblender.c
intern/source/envmap.c
intern/source/external_engine.c
intern/source/gammaCorrectionTables.c
intern/source/imagetexture.c
intern/source/initrender.c
@ -79,6 +80,7 @@ set(SRC
intern/source/voxeldata.c
intern/source/zbuf.c
extern/include/RE_engine.h
extern/include/RE_pipeline.h
extern/include/RE_render_ext.h
extern/include/RE_shader_ext.h

@ -0,0 +1,97 @@
/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2006 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file RE_engine.h
* \ingroup render
*/
#ifndef RE_ENGINE_H
#define RE_ENGINE_H
#include "DNA_listBase.h"
#include "RNA_types.h"
struct Object;
struct Render;
struct RenderEngine;
struct RenderEngineType;
struct RenderLayer;
struct RenderResult;
struct ReportList;
struct Scene;
/* External Engine */
#define RE_INTERNAL 1
#define RE_GAME 2
#define RE_DO_PREVIEW 4
#define RE_DO_ALL 8
extern ListBase R_engines;
typedef struct RenderEngineType {
struct RenderEngineType *next, *prev;
/* type info */
char idname[64]; // best keep the same size as BKE_ST_MAXNAME
char name[64];
int flag;
void (*render)(struct RenderEngine *engine, struct Scene *scene);
/* RNA integration */
ExtensionRNA ext;
} RenderEngineType;
typedef struct RenderEngine {
RenderEngineType *type;
struct Render *re;
ListBase fullresult;
} RenderEngine;
void RE_layer_load_from_file(struct RenderLayer *layer, struct ReportList *reports, const char *filename, int x, int y);
void RE_result_load_from_file(struct RenderResult *result, struct ReportList *reports, const char *filename);
struct RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h);
void RE_engine_update_result(RenderEngine *engine, struct RenderResult *result);
void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result);
int RE_engine_test_break(RenderEngine *engine);
void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
void RE_engine_report(RenderEngine *engine, int type, const char *msg);
int RE_engine_render(struct Render *re, int do_all);
/* Engine Types */
void RE_engines_init(void);
void RE_engines_exit(void);
#endif /* RE_ENGINE_H */

@ -36,7 +36,6 @@
#include "DNA_listBase.h"
#include "DNA_vec_types.h"
#include "RNA_types.h"
struct bNodeTree;
struct Image;
@ -44,11 +43,8 @@ struct Main;
struct NodeBlurData;
struct Object;
struct RenderData;
struct RenderEngine;
struct RenderEngineType;
struct RenderResult;
struct ReportList;
struct ReportList;
struct Scene;
struct SceneRenderLayer;
struct EnvMap;
@ -276,49 +272,6 @@ void RE_DataBase_GetView(struct Render *re, float mat[][4]);
void RE_GetCameraWindow(struct Render *re, struct Object *camera, int frame, float mat[][4]);
struct Scene *RE_GetScene(struct Render *re);
/* External Engine */
#define RE_INTERNAL 1
#define RE_GAME 2
#define RE_DO_PREVIEW 4
#define RE_DO_ALL 8
extern ListBase R_engines;
typedef struct RenderEngineType {
struct RenderEngineType *next, *prev;
/* type info */
char idname[64]; // best keep the same size as BKE_ST_MAXNAME
char name[64];
int flag;
void (*render)(struct RenderEngine *engine, struct Scene *scene);
/* RNA integration */
ExtensionRNA ext;
} RenderEngineType;
typedef struct RenderEngine {
RenderEngineType *type;
struct Render *re;
ListBase fullresult;
} RenderEngine;
void RE_layer_load_from_file(RenderLayer *layer, struct ReportList *reports, const char *filename, int x, int y);
void RE_result_load_from_file(RenderResult *result, struct ReportList *reports, const char *filename);
struct RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, int h);
void RE_engine_update_result(RenderEngine *engine, struct RenderResult *result);
void RE_engine_end_result(RenderEngine *engine, struct RenderResult *result);
int RE_engine_test_break(RenderEngine *engine);
void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
void RE_engine_report(RenderEngine *engine, int type, const char *msg);
void RE_engines_init(void);
void RE_engines_exit(void);
int RE_is_rendering_allowed(struct Scene *scene, struct Object *camera_override, struct ReportList *reports);
#endif /* RE_PIPELINE_H */

Some files were not shown because too many files have changed in this diff Show More