Renamed Find_last_slash() to Find_last_separator() to make purpose more clear.

Append_path():
- when adding sub directories: don't add a "/" when last separator is a ":".
- when climbing upwards: don't remove the ":" it it's the last separator.

Those fixes help the file selector for scripts on AROS.


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1979 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
mazzearos 2012-08-05 08:51:16 +00:00
parent d31b865482
commit d28a1df60b
7 changed files with 23 additions and 15 deletions

View File

@ -1197,7 +1197,7 @@ void Add_font_or_skin(const char *name)
int namelength;
// Cut the long name to keep only filename (no directory)
fname = Find_last_slash(name);
fname = Find_last_separator(name);
if (fname)
fname++;
else

View File

@ -685,7 +685,7 @@ void Main_handler(void)
Upload_infos_page_main(Main_backups->Pages);
flimit = Find_last_slash(Drop_file_name);
flimit = Find_last_separator(Drop_file_name);
*(flimit++) = '\0';
Hide_cursor();

View File

@ -33,7 +33,7 @@
#include "filesel.h" // Get_item_by_index
#include "global.h"
#include "graph.h"
#include "io.h" // find_last_slash
#include "io.h" // find_last_separator
#include "misc.h"
#include "pages.h" // Backup()
#include "readline.h"
@ -1522,7 +1522,7 @@ void Add_script(const char *name, byte is_file, byte is_directory, byte is_hidde
const char * file_name;
int len;
file_name=Find_last_slash(name)+1;
file_name=Find_last_separator(name)+1;
if (is_file)
{

View File

@ -1742,7 +1742,7 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context)
Config.Bookmark_directory[clicked_button-10]=malloc(temp+1);
strcpy(Config.Bookmark_directory[clicked_button-10],Main_current_directory);
directory_name=Find_last_slash(Main_current_directory);
directory_name=Find_last_separator(Main_current_directory);
if (directory_name && directory_name[1]!='\0')
directory_name++;
else

View File

@ -165,7 +165,7 @@ int Write_dword_be(FILE *file, dword dw)
// Attention, sous Windows, il faut s'attendre aux deux car
// par exemple un programme lancé sous GDB aura comme argv[0]:
// d:\Data\C\GFX2\grafx2/grafx2.exe
char * Find_last_slash(const char * str)
char * Find_last_separator(const char * str)
{
const char * position = NULL;
for (; *str != '\0'; str++)
@ -182,7 +182,7 @@ char * Find_last_slash(const char * str)
// Récupère la partie "nom de file seul" d'un chemin
void Extract_filename(char *dest, const char *source)
{
const char * position = Find_last_slash(source);
const char * position = Find_last_separator(source);
if (position)
strcpy(dest,position+1);
@ -195,7 +195,7 @@ void Extract_path(char *dest, const char *source)
char * position=NULL;
Realpath(source,dest);
position = Find_last_slash(dest);
position = Find_last_separator(dest);
if (position)
*(position+1) = '\0';
else
@ -217,7 +217,7 @@ void Append_path(char *path, const char *filename, char *reverse_path)
{
// Going up one directory
long len;
char * slash_pos;
char * separator_pos;
// Remove trailing slash
len=strlen(path);
@ -228,12 +228,18 @@ void Append_path(char *path, const char *filename, char *reverse_path)
))
path[len-1]='\0';
slash_pos=Find_last_slash(path);
if (slash_pos)
separator_pos=Find_last_separator(path);
if (separator_pos)
{
if (reverse_path)
strcpy(reverse_path, slash_pos+1);
*slash_pos='\0';
strcpy(reverse_path, separator_pos+1);
#if 0
// Don't strip away the colon
if (*separator_pos == ':') *(separator_pos+1)='\0';
else *separator_pos='\0';
#else
*separator_pos='\0';
#endif
}
else
{
@ -258,6 +264,8 @@ void Append_path(char *path, const char *filename, char *reverse_path)
if (len && (strcmp(path+len-1,PATH_SEPARATOR)
#ifdef __WIN32__
&& path[len-1]!='/'
#elif __AROS__
&& path[len-1]!=':' // To avoid paths like volume:/dir
#endif
))
{

View File

@ -68,7 +68,7 @@ void Extract_filename(char *dest, const char *source);
void Extract_path(char *dest, const char *source);
/// Finds the rightmost path separator in a full filename. Used to separate directory from file.
char * Find_last_slash(const char * str);
char * Find_last_separator(const char * str);
#if defined(__WIN32__)
#define PATH_SEPARATOR "\\"

View File

@ -168,7 +168,7 @@ void Add_font(const char *name)
strcpy(font->Label, " ");
if (font->Is_truetype)
font->Label[17]=font->Label[18]='T'; // Logo TT
font_name=Find_last_slash(font->Name);
font_name=Find_last_separator(font->Name);
if (font_name==NULL)
font_name=font->Name;
else