From: Kenichi Handa <handa@m17n.org>
To: MJ Chan <mjchan.inbox@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: file-attribute on certain Chinese filenames failed
Date: Tue, 13 Feb 2007 14:36:42 +0900 [thread overview]
Message-ID: <E1HGqLK-0004Nf-0P@etlken.m17n.org> (raw)
In-Reply-To: <45c9d948.5c6acfa4.4c9b.ffffeb01@mx.google.com> (message from MJ Chan on Wed, 07 Feb 2007 05:51:04 -0800 (PST))
In article <45c9d948.5c6acfa4.4c9b.ffffeb01@mx.google.com>, MJ Chan <mjchan.inbox@gmail.com> writes:
> I had trouble in accessing some files that contains certain Chinese
> (big5) characters (in fact, I found only one character so far that is
> causing the problem; all others are good). After checking around, I
> found that the problem would take place in "lstat" call in the C
> source. One example is in "file-attributes" (src/dired.c).
> For example, if I created a file named "=26345" (see below for the
> "describe-char" on that particular Chinese character) and then
> evaluated this, it returned nil.
> (file-attributes "=26345")
> nil
I can't reproduce that problem on GNU/Linux. For instance,
it seems that this code work correctly.
(let ((file-name-coding-system 'big5)
(filename (string #x26345)))
(with-temp-file filename (insert "abc\n"))
(file-attributes filename))
=> (nil 1 8308 8308 (17873 19356) (17873 19356) (17873 19356)
4 "-rw-rw-r--" nil 11175288 21)
But, when I run the same code on Windows, write-region
causes this error:
(file-error "Opening output file" "invalid argument"
"c:/cygwin/home/handa/\x26345")
I suspect that this is because the big5 sequence of the
character #x26345 is "\267|", and Windows-XP (at least my
Japanese version) doesn't allow creating a file containing
"|". For instance, I can't create a file "a|" either.
> As mentioned above, the culprit seems to be in calling lstat with
> encoded version of the file name as shown below (taken from dired.c)
> GCPRO1 (filename);
> encoded = ENCODE_FILE (filename);
> UNGCPRO;
> if (lstat (SDATA (encoded), &s) < 0)
> return Qnil;
> If I changed the call to use un-encoded filename (i.e. lstat
> (filename,...)), then it is good. But I am not sure if this is the
> right thing to do.
I believe it's not the right fix, and first of all, I have
no idea why such a change fixes your case.
Anyway, it seems that this is an Windows specific problem.
---
Kenichi Handa
handa@m17n.org
next parent reply other threads:[~2007-02-13 5:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <45c9d948.5c6acfa4.4c9b.ffffeb01@mx.google.com>
2007-02-13 5:36 ` Kenichi Handa [this message]
2007-02-13 6:06 ` file-attribute on certain Chinese filenames failed MJ Chan
2007-02-14 15:15 ` Jason Rumney
2007-02-17 12:22 ` Eli Zaretskii
2007-02-17 15:09 ` MJ Chan
2007-02-18 22:15 ` Eli Zaretskii
2007-02-19 4:03 ` MJ Chan
2007-02-23 18:41 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1HGqLK-0004Nf-0P@etlken.m17n.org \
--to=handa@m17n.org \
--cc=emacs-devel@gnu.org \
--cc=mjchan.inbox@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.