* Second attempt at fixing #448.
* Fix another bug with realpath in Haiku (relying on nonstandard behaviour) git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1917 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
8852f59a95
commit
af8316c279
@ -1292,7 +1292,7 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context)
|
||||
byte save_or_load_image=0;
|
||||
byte has_clicked_ok=0;// Indique si on a clické sur Load ou Save ou sur
|
||||
//un bouton enclenchant Load ou Save juste après.
|
||||
byte initial_back_color; // | fout en l'air (c'te conne).
|
||||
byte initial_back_color; // preview destroys it (how nice)
|
||||
char previous_directory[MAX_PATH_CHARACTERS]; // Répertoire d'où l'on vient après un CHDIR
|
||||
char save_filename[MAX_PATH_CHARACTERS];
|
||||
char initial_comment[COMMENT_SIZE+1];
|
||||
|
||||
@ -378,7 +378,9 @@ int Analyze_command_line(int argc, char * argv[], char *main_filename, char *mai
|
||||
else if (File_exists(argv[index]))
|
||||
{
|
||||
file_in_command_line ++;
|
||||
printf("PATH RESOLVE %s\n", argv[index]);
|
||||
buffer = Realpath(argv[index], NULL);
|
||||
printf("returns : %p\n", buffer);
|
||||
|
||||
if (file_in_command_line == 1)
|
||||
{
|
||||
@ -802,11 +804,13 @@ int Init_program(int argc,char * argv[])
|
||||
*Brush=MC_White;
|
||||
*Brush_original_pixels=MC_White;
|
||||
|
||||
// Make sure the load dialog pointsto the right place when first shown.
|
||||
// Make sure the load dialog points to the right place when first shown.
|
||||
// Done after loading everything else, but before checking for emergency
|
||||
// backups
|
||||
if (file_in_command_line > 0)
|
||||
chdir(main_directory);
|
||||
{
|
||||
strcpy(Main_current_directory, main_directory);
|
||||
}
|
||||
|
||||
// Test de recuperation de fichiers sauvés
|
||||
switch (Check_recovery())
|
||||
|
||||
@ -43,6 +43,8 @@
|
||||
return path;
|
||||
}
|
||||
|
||||
// Find the real path of _path by chdir to it and then getcwd.
|
||||
// If resolved_path is null, it is allocated.
|
||||
char *Realpath(const char *_path, char *resolved_path)
|
||||
{
|
||||
int fd = open(".", O_RDONLY), l;
|
||||
@ -62,23 +64,23 @@
|
||||
l = -1;
|
||||
#else
|
||||
l = readlink(path, lnk, PATH_MAX);
|
||||
#endif
|
||||
if (!(tmp = sep(path))) {
|
||||
#endif
|
||||
if (!(tmp = sep(path))) {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
}
|
||||
if (l < 0) {
|
||||
if (errno != EINVAL) {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
}
|
||||
if (l < 0) {
|
||||
if (errno != EINVAL) {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
}
|
||||
} else {
|
||||
lnk[l] = 0;
|
||||
if (!(tmp = sep(lnk))) {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
}
|
||||
} else {
|
||||
lnk[l] = 0;
|
||||
if (!(tmp = sep(lnk))) {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
resolved_path = NULL;
|
||||
goto abort;
|
||||
@ -114,6 +116,12 @@
|
||||
// Use the stdlib function.
|
||||
char *Realpath(const char *_path, char *resolved_path)
|
||||
{
|
||||
// While linux version of realpath handles the resolved_path being a
|
||||
// null pointer, this is not the case for other platforms (Haiku), nor
|
||||
// specified by the open group in POSIX. So, be safe and allocate
|
||||
// ourselves.
|
||||
if(resolved_path==NULL) // if we called realpath with null as a 2nd arg
|
||||
resolved_path = (char*) malloc( PATH_MAX );
|
||||
return realpath(_path, resolved_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user