[AD] Re: file_select_ex patch |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: [AD] Re: file_select_ex patch
- From: Chris <chris.kcat@xxxxxxxxxx>
- Date: Mon, 12 Sep 2005 16:39:05 -0700
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:to:subject:date:user-agent:references:in-reply-to:mime-version:content-disposition:content-type:message-id; b=hjTOUwKYumho03yU5W9dsIS7h8nEeQrCDeVgwhaCzUcfSSxeHf8jQuAszqoplXr8Q4pptyzwNDOvO1tFU5PPfhN1k39aZzh37pUiEqL+qapMFZGgd+8Lhb53wohBM6hIRb6lks0BSHXrPcxD8xm5KuANSBD93XOKCCMfbB21+FY=
Updated the patch. This one also causes the directories to be effected by the
attributes set in the extension string, too. The reason for this is, using
";/-h" as the extension undesireably shows directories that start with '.',
and if you used ";/-r", there is no point in showing a read-only directory
(since all the files in it will be read-only, which you don't want).
For the future, I hope to make a patch that causes the file selector to show
some common directories (/, $(HOME), $(HOME)/Desktop, etc) for Unix, where
the drive selection would normally be. But since that's going to require a
little more work, I'll wait until this patch is accepted or denied.
Index: src/fsel.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/fsel.c,v
retrieving revision 1.42
diff -u -p -r1.42 fsel.c
--- src/fsel.c 12 Mar 2005 05:59:51 -0000 1.42
+++ src/fsel.c 12 Sep 2005 23:26:19 -0000
@@ -421,16 +421,16 @@ static int fs_flist_putter(AL_CONST char
}
return 0;
}
+ }
- Next:
- /* Check if file attributes match. */
- if (check_attrib) {
- for (c=0; c<ATTRB_MAX; c++) {
- if ((attrb_state[c] == ATTRB_SET) && (!(attrib & attrb_flag[c])))
- return 0;
- if ((attrb_state[c] == ATTRB_UNSET) && (attrib & attrb_flag[c]))
- return 0;
- }
+ Next:
+ /* Check if file attributes match. */
+ if (check_attrib) {
+ for (c=0; c<ATTRB_MAX; c++) {
+ if ((attrb_state[c] == ATTRB_SET) && (!(attrib & attrb_flag[c])))
+ return 0;
+ if ((attrb_state[c] == ATTRB_UNSET) && (attrib & attrb_flag[c]))
+ return 0;
}
}
@@ -843,11 +843,15 @@ int file_select_ex(AL_CONST char *messag
{
static attrb_state_t default_attrb_state[ATTRB_MAX] = DEFAULT_ATTRB_STATE;
int ret;
- char *p;
+ char *p, *backup;
char tmp[32];
ASSERT(message);
ASSERT(path);
+ backup = ustrdup(path);
+ if (!backup)
+ return FALSE;
+
if (width == OLD_FILESEL_WIDTH)
width = 305;
@@ -918,11 +922,19 @@ int file_select_ex(AL_CONST char *messag
fext_p = NULL;
}
- if ((ret == FS_CANCEL) || (!ugetc(get_filename(path))))
+ if (ret == FS_CANCEL) {
+ ustrcpy(path, backup);
+ free(backup);
+ return FALSE;
+ }
+
+ free(backup);
+
+ if (!ugetc(get_filename(path)))
return FALSE;
p = get_extension(path);
- if ((!ugetc(p)) && (ext) && (!ustrpbrk(ext, uconvert_ascii(" ,;", tmp)))) {
+ if ((!ugetc(p)) && (ext) && (ugetc(ext)) && (!ustrpbrk(ext, uconvert_ascii(" ,;", tmp)))) {
size -= ((long)p - (long)path + ucwidth('.'));
if (size >= uwidth_max(U_CURRENT) + ucwidth(0)) { /* do not end with '.' */
p += usetc(p, '.');