Fixes opening video files on Windows. [#30752]

Thanks Lockal for finding faulty stat function which helped a lot. 
Now there BLI_stat. I will replace all other stat later.

*** Please use BLI_xxxx() functions ***
for file operations

Reported by Leon Cheung, Lockal, Believil
This commit is contained in:
2012-05-01 21:46:55 +00:00
parent 5cd4b32b38
commit 274d3d2daa
3 changed files with 23 additions and 2 deletions

View File

@@ -55,6 +55,7 @@ int BLI_rename(const char *from, const char *to);
int BLI_delete(const char *path, int dir, int recursive); int BLI_delete(const char *path, int dir, int recursive);
int BLI_move(const char *path, const char *to); int BLI_move(const char *path, const char *to);
int BLI_create_symlink(const char *path, const char *to); int BLI_create_symlink(const char *path, const char *to);
int BLI_stat(const char *path, struct stat *buffer);
/* Directories */ /* Directories */

View File

@@ -493,6 +493,23 @@ int BLI_exists(const char *name)
return(st.st_mode); return(st.st_mode);
} }
#ifdef WIN32
int BLI_stat(const char *path, struct stat *buffer)
{
int r;
UTF16_ENCODE(path);
r=_wstat(path_16,buffer);
UTF16_UN_ENCODE(path);
return r;
}
#else
int BLI_stat(const char *path, struct stat *buffer)
{
return stat(path, buffer);
}
#endif
/* would be better in fileops.c except that it needs stat.h so add here */ /* would be better in fileops.c except that it needs stat.h so add here */
int BLI_is_dir(const char *file) int BLI_is_dir(const char *file)
{ {

View File

@@ -40,6 +40,7 @@
#endif #endif
#include "BLI_blenlib.h" #include "BLI_blenlib.h"
#include "BLI_fileops.h"
#include "DNA_userdef_types.h" #include "DNA_userdef_types.h"
#include "BKE_global.h" #include "BKE_global.h"
@@ -342,14 +343,14 @@ int imb_get_anim_type(const char * name)
/* stat test below fails on large files > 4GB */ /* stat test below fails on large files > 4GB */
if (isffmpeg(name)) return (ANIM_FFMPEG); if (isffmpeg(name)) return (ANIM_FFMPEG);
# endif # endif
if (stat(name, &st) == -1) return(0); if (BLI_stat(name, &st) == -1) return(0);
if (((st.st_mode) & S_IFMT) != S_IFREG) return(0); if (((st.st_mode) & S_IFMT) != S_IFREG) return(0);
if (isavi(name)) return (ANIM_AVI); if (isavi(name)) return (ANIM_AVI);
if (ismovie(name)) return (ANIM_MOVIE); if (ismovie(name)) return (ANIM_MOVIE);
#else #else
if (stat(name, &st) == -1) return(0); if (BLI_stat(name, &st) == -1) return(0);
if (((st.st_mode) & S_IFMT) != S_IFREG) return(0); if (((st.st_mode) & S_IFMT) != S_IFREG) return(0);
if (ismovie(name)) return (ANIM_MOVIE); if (ismovie(name)) return (ANIM_MOVIE);
@@ -359,6 +360,8 @@ int imb_get_anim_type(const char * name)
# ifdef WITH_FFMPEG # ifdef WITH_FFMPEG
if (isffmpeg(name)) return (ANIM_FFMPEG); if (isffmpeg(name)) return (ANIM_FFMPEG);
# endif # endif
if (isavi(name)) return (ANIM_AVI); if (isavi(name)) return (ANIM_AVI);
#endif #endif
#ifdef WITH_REDCODE #ifdef WITH_REDCODE