getcwd() => Get_current_directory()
This commit is contained in:
parent
2ef2e04a7e
commit
62944c724e
@ -2010,7 +2010,7 @@ int L_Run(lua_State* L)
|
||||
return luaL_error(L, "run: too many nested calls (100)");
|
||||
|
||||
// store the current directory (on the stack)
|
||||
getcwd(saved_directory,MAX_PATH_CHARACTERS);
|
||||
Get_current_directory(saved_directory,MAX_PATH_CHARACTERS);
|
||||
|
||||
#if defined (__AROS__)
|
||||
// Convert path written on Linux/Windows norms to AROS norms :
|
||||
|
||||
@ -438,13 +438,8 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
|
||||
const char * current_path = NULL;
|
||||
char curdir[MAX_PATH_CHARACTERS];
|
||||
#if defined (__MINT__)
|
||||
char path[1024]={0};
|
||||
char path2[1024]={0};
|
||||
char currentDrive=0;
|
||||
T_Fileselector_item *item=0;
|
||||
bool bFound=false;
|
||||
path[0]='\0';
|
||||
path2[0]='\0';
|
||||
#endif
|
||||
|
||||
callback_data.list = list;
|
||||
@ -456,19 +451,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
|
||||
// Après effacement, il ne reste ni fichier ni répertoire dans la liste
|
||||
|
||||
// On lit tous les répertoires:
|
||||
|
||||
#if defined (__MINT__)
|
||||
currentDrive='A';
|
||||
currentDrive=currentDrive+Dgetdrv();
|
||||
|
||||
Dgetpath(path,0);
|
||||
sprintf(path2,"%c:\%s",currentDrive,path);
|
||||
|
||||
strcat(path2,PATH_SEPARATOR);
|
||||
current_path=path2;
|
||||
#else
|
||||
current_path=getcwd(curdir,MAX_PATH_CHARACTERS);
|
||||
#endif
|
||||
current_path = Get_current_directory(curdir, MAX_PATH_CHARACTERS);
|
||||
|
||||
For_each_directory_entry(current_path, &callback_data, Read_dir_callback);
|
||||
|
||||
@ -1535,20 +1518,8 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
|
||||
Display_bookmark(bookmark_dropdown[temp],temp);
|
||||
}
|
||||
|
||||
#if defined(__MINT__)
|
||||
{
|
||||
static char path[1024]={0};
|
||||
chdir(context->File_directory);
|
||||
Dgetpath(path,0);
|
||||
strcat(path,PATH_SEPARATOR);
|
||||
strcpy(Selector->Directory,path);
|
||||
}
|
||||
#else
|
||||
{
|
||||
chdir(context->File_directory);
|
||||
getcwd(Selector->Directory,MAX_PATH_CHARACTERS);
|
||||
}
|
||||
#endif
|
||||
chdir(context->File_directory);
|
||||
Get_current_directory(Selector->Directory,MAX_PATH_CHARACTERS);
|
||||
|
||||
// Affichage des premiers fichiers visibles:
|
||||
Reload_list_of_files(Selector->Format_filter,file_scroller);
|
||||
@ -2092,13 +2063,7 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context
|
||||
Extract_filename(previous_directory, Selector->Directory);
|
||||
}
|
||||
|
||||
#if defined (__MINT__)
|
||||
currentDrive=currentDrive+Dgetdrv();
|
||||
Dgetpath(path,0);
|
||||
sprintf(Selector->Directory,"%c:\%s",currentDrive,path);
|
||||
#else
|
||||
getcwd(Selector->Directory,MAX_PATH_CHARACTERS);
|
||||
#endif
|
||||
Get_current_directory(Selector->Directory,MAX_PATH_CHARACTERS);
|
||||
// read the new directory
|
||||
Read_list_of_files(&Filelist, Selector->Format_filter);
|
||||
Sort_list_of_files(&Filelist);
|
||||
|
||||
16
src/io.c
16
src/io.c
@ -2,6 +2,7 @@
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2018 Thomas Bernard
|
||||
Copyright 2011 Pawel Góralski
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 2007 Adrien Destugues
|
||||
@ -524,3 +525,18 @@ void Release_lock_file(const char *file_directory)
|
||||
strcat(lock_filename,"gfx2.lck");
|
||||
remove(lock_filename);
|
||||
}
|
||||
|
||||
const char * Get_current_directory(char * buf, size_t size)
|
||||
{
|
||||
#if defined(__MINT__)
|
||||
buf[0] = 'A'+Dgetdrv();
|
||||
buf[1] = ':';
|
||||
buf[2] = '\\';
|
||||
Dgetpath(buf+3,0);
|
||||
strcat(buf,PATH_SEPARATOR);
|
||||
|
||||
return buf;
|
||||
#else
|
||||
return getcwd(buf, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
5
src/io.h
5
src/io.h
@ -2,6 +2,7 @@
|
||||
*/
|
||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||
|
||||
Copyright 2018 Thomas Bernard
|
||||
Copyright 2011 Pawel Góralski
|
||||
Copyright 2008 Yves Rizoud
|
||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||
@ -30,6 +31,7 @@
|
||||
/// - fstat()
|
||||
/// - opendir()
|
||||
/// - readdir()
|
||||
/// - getcwd()
|
||||
/// - Also, don't assume "/" or "\\", use PATH_SEPARATOR
|
||||
/// If you don't, you break another platform.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -125,3 +127,6 @@ byte Create_lock_file(const char *file_directory);
|
||||
/// Release a lock file created by ::Create_lock_file
|
||||
void Release_lock_file(const char *file_directory);
|
||||
|
||||
///
|
||||
/// Return the current directory, equivalent to getcwd()
|
||||
const char * Get_current_directory(char * buf, size_t size);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user