all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: MJ Chan <mjchan.inbox@gmail.com>
To: Kenichi Handa <handa@m17n.org>
Cc: emacs-devel@gnu.org
Subject: Re: file-attribute on certain Chinese filenames failed
Date: Tue, 13 Feb 2007 01:06:39 -0500	[thread overview]
Message-ID: <17873.21871.414000.223392@MJ.T40.T40> (raw)
In-Reply-To: <E1HGqLK-0004Nf-0P@etlken.m17n.org>

Thanks for looking into the problem. 

The same code you used did not cause write-region to fail on my
XP. That is, the file "會" was written correctly. But again,
file-attributes returned nil.

Also, if I use utf-8, then file-attributes reports incorrectly the
file as a directory as shown below. This is odd.

(let ((file-name-coding-system 'utf-8))
  (file-attributes "會"))
=> (t 1 5 5 (17873 20762) (17873 20755) (17430 62310) 0 "drwxrwxrwx" nil 0 (41075 . 32279))

(let ((file-name-coding-system 'big5))
  (file-attributes "會"))
=> nil

If you have other clue, please let me know.

BTW, My machine is running English XP with Big5 (Chinese/Taiwan) set for
non-Unicode program in Regional and Language Options in Control Panel.

>>>>> On Tuesday, February 13 2007, Kenichi Handa said:

    > 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

  reply	other threads:[~2007-02-13  6:06 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 ` file-attribute on certain Chinese filenames failed Kenichi Handa
2007-02-13  6:06   ` MJ Chan [this message]
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=17873.21871.414000.223392@MJ.T40.T40 \
    --to=mjchan.inbox@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=handa@m17n.org \
    /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.