new utility function for BLI_storage.h - BLI_is_dir

currently unsupported on windows.

should fix this too [#19656] N-Panel in filebrowser not working
though typing in invalid names then becomes possible
This commit is contained in:
Campbell Barton 2009-10-16 10:22:11 +00:00
parent 59f330cce0
commit 5938b4c93e
3 changed files with 13 additions and 1 deletions

View File

@ -66,6 +66,9 @@ int BLI_exist(char *name);
* @param name The name of the file to read.
* @retval A list of strings representing the file lines.
*/
int BLI_is_dir(char *file);
struct LinkNode *BLI_read_file_as_lines(char *name);
/**

View File

@ -468,6 +468,15 @@ int BLI_exist(char *name)
return(st.st_mode);
}
/* would be better in fileops.c except that it needs stat.h so add here */
int BLI_is_dir(char *file) {
#ifdef WIN32
return 1; /* XXX - TODO */
#else
return S_ISDIR(BLI_exist(file));
#endif
}
LinkNode *BLI_read_file_as_lines(char *name)
{
FILE *fp= fopen(name, "r");

View File

@ -388,7 +388,7 @@ void file_change_dir(struct SpaceFile *sfile, int checkdir)
{
if (sfile->params) {
if(checkdir && S_ISDIR(BLI_exists(sfile->params->dir)) == 0) {
if(checkdir && BLI_is_dir(sfile->params->dir)==0) {
BLI_strncpy(sfile->params->dir, filelist_dir(sfile->files), sizeof(sfile->params->dir));
/* could return but just refresh the current dir */
}