- int dirlen = 0;
-
- f_fname = malloc( strlen(tmp) );
- if( f_fname )
- strcpy( f_fname, tmp+1 ); // we skip the seperator, so it will still fit in the allocated space
- dirlen = strlen(psz_fname) - strlen(tmp) + 1; // add the seperator
- f_dir = malloc( dirlen + 1 );
- if( f_dir )
- {
- strncpy( f_dir, psz_fname, dirlen );
- f_dir[dirlen] = 0;
- }
- }
- else
- {
- /* Get the current working directory */
- int dirlen;
-#ifdef HAVE_UNISTD_H
- f_dir = getcwd( NULL, 0 );
-#endif
- if( f_dir == NULL )
- {
- if( psz_fname_original ) free( psz_fname_original );
- return NULL;
- }
- dirlen = strlen( f_dir );
- f_dir = (char *)realloc(f_dir, dirlen +2 );
- f_dir[dirlen] = DIRECTORY_SEPARATOR;
- f_dir[dirlen+1] = '\0';
- f_fname = FromLocaleDup( psz_fname );