bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Apprent bug in directory-files-and-attributes


From: Whitfield Diffie
Subject: Apprent bug in directory-files-and-attributes
Date: Mon, 16 Feb 2004 12:19:36 -0800

                                Sunday  15 February 2004  at 17:16

    I have a case in which directory-files-and-attributes returns a list
in which some entries are of the form (<filename>), i.e., the attributes
portion is nil.  I believe the filename portion is correct.

    Unfortunately, this is a directory of files with very ill-behaved
names.  The names were manufactured from the `from addresses' of incoming
spam.  As far as I can tell, however, the directory itself is well formed
and the files actually exist.

    I conjecture that diectory-files-and-attributes has been implemented by
calling directory-files and then applying file-attributes to each element
of this list.  Certainly file-attributes (or file-exists-p) fails to find
the files under any encoding I can think to apply.

    I apologize for the plethera of evidence below.  I include it because
I am worried that the tar file of the directory (which is the basic evidence)
might not come out exactly the same on some other system.

                                Thanks,
                                        Whit

Listing the directory from-logs-1 with ls -l on a Powerbook G4, produces:

total 80
-rw-------  1 diffie  staff  61 Apr 18  2003 address@hidden
-rw-------  1 diffie  staff  81 Apr  6  2003 address@hidden
-rw-------  1 diffie  staff  78 Apr  9  2003 
?????????mms02es.mms.us.syntegra.com
-rw-------  1 diffie  staff  76 Apr 16  2003 
????????????ms11es.mms.us.syntegra.com
-rw-------  1 diffie  staff  70 Apr 17  2003 ???????mms12es.mms.us.syntegra.com
-rw-------  1 diffie  staff  73 Apr 12  2003 
????????????ms11es.mms.us.syntegra.com
-rw-------  1 diffie  staff  66 Apr 14  2003 
?????????mms02es.mms.us.syntegra.com
-rw-------  1 diffie  staff  72 Apr 13  2003 
?????????mms12es.mms.us.syntegra.com
-rw-------  1 diffie  staff  72 Apr  9  2003 ?????????s12es.mms.us.syntegra.com
-rw-------  1 diffie  staff  66 Apr 16  2003 ??????ms12es.mms.us.syntegra.com


    From the directory superior to from-logs-1,

    (let ((files (cddr (directory-files-and-attributes "from-logs-1"))) (cnt 0))
      (while files
        (insert (encode-coding-string (stringify (nth cnt aa)) 'raw-text) "\n")
        (setq cnt (1+ cnt))
        (setq files (cdr files)))))

produces:

("address@hidden" nil 1 504 20 (16432 6555) (16032 32322) (16422 40168) 61 
"-rw-------" nil 4469272 -33554427)
("address@hidden" nil 1 504 20 (16432 6555) (16017 1488) (16422 40168) 81 
"-rw-------" nil 4469273 -33554427)
("á¤¾íº¢í½\200mms02es.mms.us.syntegra.com")
("᥹á\204\201á\205¯á\207\200ms11es.mms.us.syntegra.com")
("㹧ñ±¨\200mms12es.mms.us.syntegra.com")
("è±¹á\204\201á\205¯á\207\200ms11es.mms.us.syntegra.com")
("è²¼í½\206í³\200mms02es.mms.us.syntegra.com")
("èµ¡íº¢í½\200mms12es.mms.us.syntegra.com")
("è·¨í\236¾í¼­s12es.mms.us.syntegra.com")
("黽■ms12es.mms.us.syntegra.com" nil 1 504 20 (16432 6555) (16029 42474) 
(16422 40121) 66 "-rw-------" nil 4467995 -33554427)

which shows that seven of ten of the files have no attributes but doesn't give 
(me)
much insight into the filenames.  (I have no explanation for the newline 
character in
the middle of the attributes of the last entry.)

    Alternatively, given the subordinate definition:

(defun string-to-raw-text-vector (string)

  " String-to-raw-text-vector converts a string to a vector of the
   character codes of the characters in the string."

  (let* ((string (encode-coding-string string 'raw-text))
         (string-length (length string)) (cnt 0)
         (vector (make-vector string-length 0)))
    (while (< cnt string-length)
      (aset vector cnt (aref string cnt))
      (setq cnt (1+ cnt)))
    vector))

the expression:

        (let ((files (cddr (directory-files-and-attributes "from-logs-1")))
              (cnt 0))
          (while files
            (insert (prin1-to-string
                     (string-to-raw-text-vector (car (nth cnt aa))))
                    "\n")
            (setq cnt (1+ cnt))
            (setq files (cdr files))))

produces:

[122 121 108 50 48 64 99 97 109 46 97 99 46 117 107]
[122 122 97 97 57 50 56 55 50 51 97 64 104 111 116 109 97 105 108 46 99 111 109]
[129 225 129 164 129 190 129 237 129 186 129 162 129 237 129 189 128 109 109 
115 48 50 101 115 46 109 109 115 46 117 115 46 115 121 110 116 101 103 114 97 
46 99 111 109]
[129 225 129 165 129 185 129 225 132 129 129 225 133 129 175 129 225 135 128 
109 115 49 49 101 115 46 109 109 115 46 117 115 46 115 121 110 116 101 103 114 
97 46 99 111 109]
[129 227 129 185 129 167 129 241 129 177 129 168 128 109 109 115 49 50 101 115 
46 109 109 115 46 117 115 46 115 121 110 116 101 103 114 97 46 99 111 109]
[129 232 129 177 129 185 129 225 132 129 129 225 133 129 175 129 225 135 128 
109 115 49 49 101 115 46 109 109 115 46 117 115 46 115 121 110 116 101 103 114 
97 46 99 111 109]
[129 232 129 178 129 188 129 237 129 189 134 129 237 129 179 128 109 109 115 48 
50 101 115 46 109 109 115 46 117 115 46 115 121 110 116 101 103 114 97 46 99 
111 109]
[129 232 129 181 129 161 129 237 129 186 129 162 129 237 129 189 128 109 109 
115 49 50 101 115 46 109 109 115 46 117 115 46 115 121 110 116 101 103 114 97 
46 99 111 109]
[129 232 129 183 129 168 129 237 158 129 190 129 237 129 188 129 173 115 49 50 
101 115 46 109 109 115 46 117 115 46 115 121 110 116 101 103 114 97 46 99 111 
109]
[129 233 129 187 129 189 129 239 129 191 129 173 109 115 49 50 101 115 46 109 
109 115 46 117 115 46 115 121 110 116 101 103 114 97 46 99 111 109]

Attachment: from-logs-1.tar
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]