From a47d94f75f4099c5fcc1ed8a85fad456a0d7537f Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 29 Jul 2009 17:39:03 +0000 Subject: [PATCH] add file-or-directory-identity (4.1.2.5) svn: r15623 --- collects/scheme/private/modbeg.ss | 4 +- collects/scribble/decode.ss | 22 ++- .../scribblings/reference/file-ports.scrbl | 12 +- .../scribblings/reference/filesystem.scrbl | 16 ++ collects/scribblings/scribble/decode.scrbl | 13 +- doc/release-notes/mzscheme/HISTORY.txt | 3 + src/mzscheme/src/cstartup.inc | 158 +++++++++--------- src/mzscheme/src/file.c | 75 ++++++++- src/mzscheme/src/port.c | 2 +- src/mzscheme/src/schminc.h | 2 +- src/mzscheme/src/schpriv.h | 2 +- src/mzscheme/src/schvers.h | 4 +- 12 files changed, 200 insertions(+), 113 deletions(-) diff --git a/collects/scheme/private/modbeg.ss b/collects/scheme/private/modbeg.ss index ba9cfd3b1c..9bda73295f 100644 --- a/collects/scheme/private/modbeg.ss +++ b/collects/scheme/private/modbeg.ss @@ -7,7 +7,9 @@ (#%provide module-begin) (define-values (print-values) - (lambda vs (for-each (current-print) vs))) + (lambda vs + (for-each (current-print) vs) + (apply values vs))) (define-syntaxes (module-begin) (lambda (stx) diff --git a/collects/scribble/decode.ss b/collects/scribble/decode.ss index 588344352f..ee64f3c99c 100644 --- a/collects/scribble/decode.ss +++ b/collects/scribble/decode.ss @@ -11,7 +11,8 @@ (and (content? i) (not (list? i))) (and (splice? i) - (andmap pre-content? (splice-run i))))) + (andmap pre-content? (splice-run i))) + (void? i))) (define (pre-flow? i) (or (string? i) @@ -19,7 +20,8 @@ (not (list? i))) (block? i) (and (splice? i) - (andmap pre-flow? (splice-run i))))) + (andmap pre-flow? (splice-run i))) + (void? i))) (define (pre-part? v) (or (pre-flow? v) @@ -150,6 +152,8 @@ l)) (decode-accum-para accum) null))] + [(void? (car l)) + (loop (cdr l) next? keys colls accum title tag-prefix tags vers style)] [(title-decl? (car l)) (cond [(not part-depth) (error 'decode "misplaced title: ~e" (car l))] [title (error 'decode "found extra title: ~v" (car l))] @@ -267,6 +271,7 @@ (define (match-newline-whitespace l) (cond [(null? l) #f] + [(void? (car l)) (match-newline-whitespace (cdr l))] [(line-break? (car l)) (skip-whitespace l)] [(splice? (car l)) (match-newline-whitespace (append (splice-run (car l)) (cdr l)))] @@ -274,9 +279,11 @@ [else #f])) (define (skip-whitespace l) - (if (or (null? l) (not (whitespace? (car l)))) - l - (skip-whitespace (cdr l)))) + (if (or (null? l) + (not (or (whitespace? (car l)) + (void? (car l))))) + l + (skip-whitespace (cdr l)))) (define (decode l) (decode-part l null #f 0)) @@ -285,7 +292,10 @@ (make-paragraph plain (decode-content l))) (define (decode-content l) - (append-map (lambda (s) (if (string? s) (decode-string s) (list s))) + (append-map (lambda (s) (cond + [(string? s) (decode-string s)] + [(void? s) null] + [else (list s)])) (skip-whitespace l))) (define (decode-compound-paragraph l) diff --git a/collects/scribblings/reference/file-ports.scrbl b/collects/scribblings/reference/file-ports.scrbl index 8a74c423e2..12f3e1ef82 100644 --- a/collects/scribblings/reference/file-ports.scrbl +++ b/collects/scribblings/reference/file-ports.scrbl @@ -297,18 +297,18 @@ the current output port (see @scheme[current-output-port]) using (lambda () (read-string 5))) ]} -@defproc[(port-file-identity [port file-stream-port?]) any]{ +@defproc[(port-file-identity [port file-stream-port?]) exact-positive-integer?]{ -@index['("inode")]{Returns} an exact positive integer that represents +@index['("inode")]{Returns} a number that represents the identity of the device and file read or written by -@scheme[file-stream-port]. For two ports whose open times overlap, the +@scheme[port]. For two ports whose open times overlap, the result of @scheme[port-file-identity] is the same for both ports if and only if the ports access the same device and file. For ports whose -open times do not overlap, no guarantee is provided for the port +open times do not overlap, no guarantee can be provided for the port identities (even if the ports actually access the same file)---except as can be inferred through relationships with other ports. If -@scheme[file-stream-port] is closed, the @exnraise[exn:fail]. Under -Windows 95, 98, and Me, if @scheme[file-stream-port] is connected to a +@scheme[port] is closed, the @exnraise[exn:fail]. Under +Windows 95, 98, and Me, if @scheme[port] is connected to a pipe instead of a file, the @exnraise[exn:fail:filesystem]. @file-examples[ diff --git a/collects/scribblings/reference/filesystem.scrbl b/collects/scribblings/reference/filesystem.scrbl index ff92419531..329eb609de 100644 --- a/collects/scribblings/reference/filesystem.scrbl +++ b/collects/scribblings/reference/filesystem.scrbl @@ -285,6 +285,22 @@ given file or directory path. On error (e.g., if no such file exists), the @exnraise[exn:fail:filesystem]. Under @|AllUnix|, permissions are checked for the current effective user instead of the real user.} + +@defproc[(file-or-directory-identity [path path-string?] + [as-link? any/c #f]) + exact-positive-integer?]{ + +@index['("inode")]{Returns} a number that represents the identity of +@scheme[path] in terms of the device and file or directory that it +accesses. This function can be used to check whether two paths +correspond to the same filesystem entity under the assumption that the +path's entity selection does not change. + +If @scheme[as-link?] is a true value, then if @scheme[path] refers to +a filesystem link, the identity of the link is returned instead of the +identity of the referenced file or directory (if any).} + + @defproc[(file-size [path path-string?]) exact-nonnegative-integer?]{ Returns the (logical) size of the specified file in bytes. Under Mac diff --git a/collects/scribblings/scribble/decode.scrbl b/collects/scribblings/scribble/decode.scrbl index 07d46937ec..292bc6a7a7 100644 --- a/collects/scribblings/scribble/decode.scrbl +++ b/collects/scribblings/scribble/decode.scrbl @@ -59,9 +59,9 @@ Pre-content is decoded into @tech{content} by functions like @defproc[(pre-flow? [v any/c]) boolean?]{ Returns @scheme[#t] if @scheme[v] is a @deftech{pre-flow} value: a -string or other non-list @scheme[content], a @scheme[block], or a -@scheme[splice] containing a list of @tech{pre-flow} values; otherwise -returns @scheme[#f]. +string or other non-list @scheme[content], a @scheme[block], +@|void-const|, or a @scheme[splice] containing a list of +@tech{pre-flow} values; otherwise returns @scheme[#f]. Pre-flow is decoded into a @tech{flow} (i.e., a list of @tech{blocks}) by functions like @scheme[decode-flow].} @@ -73,8 +73,8 @@ Returns @scheme[#t] if @scheme[v] is a @deftech{pre-part} value: a string or other non-list @scheme[content], a @scheme[block], a @scheme[part], a @scheme[title-decl], a @scheme[part-start], a @scheme[part-index-decl], a @scheme[part-collect-decl], a -@scheme[part-tag-decl], or a @scheme[splice] containing a list of -@tech{pre-part} values; otherwise returns @scheme[#f]. +@scheme[part-tag-decl], @|void-const|, or a @scheme[splice] containing +a list of @tech{pre-part} values; otherwise returns @scheme[#f]. A pre-part sequences is decoded into a @scheme[part] by functions like @scheme[decode] and @scheme[decode-part].} @@ -93,9 +93,8 @@ of @scheme[part-tag-decl] add hyperlink tags to the section title. Instances of @scheme[part-start] at level 0 trigger sub-part parsing. Instances of @scheme[section] trigger are used as-is as subsections, and instances of @scheme[paragraph] and other -flow-element datatypes are used as-is in the enclosing flow. +flow-element datatypes are used as-is in the enclosing flow.} -} @defproc[(decode-part [lst (listof pre-part?)] [tags (listof string?)] diff --git a/doc/release-notes/mzscheme/HISTORY.txt b/doc/release-notes/mzscheme/HISTORY.txt index 860b7773bc..a7bb6393e6 100644 --- a/doc/release-notes/mzscheme/HISTORY.txt +++ b/doc/release-notes/mzscheme/HISTORY.txt @@ -1,3 +1,6 @@ +Version 4.2.1.5 +Added file-or-directory-identity + Version 4.2.1, July 2009 Added string->unreadable-symbol and symbol-interned? Added syntax-local-lift-provide diff --git a/src/mzscheme/src/cstartup.inc b/src/mzscheme/src/cstartup.inc index 32a2e788b9..dd53380452 100644 --- a/src/mzscheme/src/cstartup.inc +++ b/src/mzscheme/src/cstartup.inc @@ -1,42 +1,42 @@ { - static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,50,46,48,46,54,50,0,0,0,1,0,0,3,0,12,0, -17,0,20,0,27,0,40,0,47,0,51,0,58,0,63,0,68,0,72,0,78, + static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,50,46,49,46,53,50,0,0,0,1,0,0,3,0,12,0, +19,0,23,0,28,0,41,0,44,0,49,0,56,0,63,0,67,0,72,0,78, 0,92,0,106,0,109,0,115,0,119,0,121,0,132,0,134,0,148,0,155,0, 177,0,179,0,193,0,1,1,27,1,35,1,43,1,53,1,89,1,122,1,155, 1,214,1,24,2,102,2,168,2,173,2,193,2,84,3,104,3,155,3,221,3, 106,4,248,4,44,5,67,5,146,5,0,0,93,7,0,0,29,11,11,68,104, -101,114,101,45,115,116,120,64,99,111,110,100,62,111,114,66,108,101,116,114,101, -99,72,112,97,114,97,109,101,116,101,114,105,122,101,66,117,110,108,101,115,115, -63,108,101,116,66,100,101,102,105,110,101,64,119,104,101,110,64,108,101,116,42, -63,97,110,100,65,113,117,111,116,101,29,94,2,13,68,35,37,107,101,114,110, +101,114,101,45,115,116,120,66,100,101,102,105,110,101,63,97,110,100,64,108,101, +116,42,72,112,97,114,97,109,101,116,101,114,105,122,101,62,111,114,64,99,111, +110,100,66,108,101,116,114,101,99,66,117,110,108,101,115,115,63,108,101,116,64, +119,104,101,110,65,113,117,111,116,101,29,94,2,13,68,35,37,107,101,114,110, 101,108,11,29,94,2,13,68,35,37,112,97,114,97,109,122,11,62,105,102,65, 98,101,103,105,110,63,115,116,120,61,115,70,108,101,116,45,118,97,108,117,101, 115,61,120,73,108,101,116,114,101,99,45,118,97,108,117,101,115,66,108,97,109, 98,100,97,1,20,112,97,114,97,109,101,116,101,114,105,122,97,116,105,111,110, 45,107,101,121,61,118,73,100,101,102,105,110,101,45,118,97,108,117,101,115,97, -35,11,8,160,243,95,159,2,15,35,35,159,2,14,35,35,159,2,14,35,35, -16,20,2,3,2,1,2,5,2,1,2,6,2,1,2,7,2,1,2,8,2, -1,2,9,2,1,2,10,2,1,2,4,2,1,2,11,2,1,2,12,2,1, -97,36,11,8,160,243,93,159,2,14,35,36,16,2,2,2,161,2,1,36,2, -2,2,1,2,2,96,11,11,8,160,243,16,0,96,37,11,8,160,243,16,0, +35,11,8,171,244,95,159,2,15,35,35,159,2,14,35,35,159,2,14,35,35, +16,20,2,3,2,1,2,7,2,1,2,4,2,1,2,5,2,1,2,8,2, +1,2,9,2,1,2,6,2,1,2,10,2,1,2,11,2,1,2,12,2,1, +97,36,11,8,171,244,93,159,2,14,35,36,16,2,2,2,161,2,1,36,2, +2,2,1,2,2,96,11,11,8,171,244,16,0,96,37,11,8,171,244,16,0, 13,16,4,35,29,11,11,2,1,11,18,16,2,99,64,104,101,114,101,8,31, -8,30,8,29,8,28,8,27,93,8,224,231,60,0,0,95,9,8,224,231,60, +8,30,8,29,8,28,8,27,93,8,224,50,61,0,0,95,9,8,224,50,61, 0,0,2,1,27,248,22,137,4,195,249,22,130,4,80,158,38,35,251,22,77, 2,16,248,22,92,199,12,249,22,67,2,17,248,22,94,201,27,248,22,137,4, 195,249,22,130,4,80,158,38,35,251,22,77,2,16,248,22,92,199,249,22,67, 2,17,248,22,94,201,12,27,248,22,69,248,22,137,4,196,28,248,22,75,193, 20,15,159,36,35,36,28,248,22,75,248,22,69,194,248,22,68,193,249,22,130, -4,80,158,38,35,251,22,77,2,16,248,22,68,199,249,22,67,2,12,248,22, +4,80,158,38,35,251,22,77,2,16,248,22,68,199,249,22,67,2,4,248,22, 69,201,11,18,16,2,101,10,8,31,8,30,8,29,8,28,8,27,16,4,11, -11,2,18,3,1,8,101,110,118,49,48,50,50,51,16,4,11,11,2,19,3, -1,8,101,110,118,49,48,50,50,52,93,8,224,232,60,0,0,95,9,8,224, -232,60,0,0,2,1,27,248,22,69,248,22,137,4,196,28,248,22,75,193,20, +11,2,18,3,1,8,101,110,118,49,48,51,49,56,16,4,11,11,2,19,3, +1,8,101,110,118,49,48,51,49,57,93,8,224,51,61,0,0,95,9,8,224, +51,61,0,0,2,1,27,248,22,69,248,22,137,4,196,28,248,22,75,193,20, 15,159,36,35,36,28,248,22,75,248,22,69,194,248,22,68,193,249,22,130,4, 80,158,38,35,250,22,77,2,20,248,22,77,249,22,77,248,22,77,2,21,248, -22,68,201,251,22,77,2,16,2,21,2,21,249,22,67,2,4,248,22,69,204, +22,68,201,251,22,77,2,16,2,21,2,21,249,22,67,2,7,248,22,69,204, 18,16,2,101,11,8,31,8,30,8,29,8,28,8,27,16,4,11,11,2,18, -3,1,8,101,110,118,49,48,50,50,54,16,4,11,11,2,19,3,1,8,101, -110,118,49,48,50,50,55,93,8,224,233,60,0,0,95,9,8,224,233,60,0, +3,1,8,101,110,118,49,48,51,50,49,16,4,11,11,2,19,3,1,8,101, +110,118,49,48,51,50,50,93,8,224,52,61,0,0,95,9,8,224,52,61,0, 0,2,1,248,22,137,4,193,27,248,22,137,4,194,249,22,67,248,22,77,248, 22,68,196,248,22,69,195,27,248,22,69,248,22,137,4,23,197,1,249,22,130, 4,80,158,38,35,28,248,22,53,248,22,131,4,248,22,68,23,198,2,27,249, @@ -50,8 +50,8 @@ 80,158,38,35,250,22,78,2,22,249,22,2,32,0,89,162,8,44,36,46,9, 222,33,42,248,22,137,4,248,22,68,201,248,22,69,198,27,248,22,69,248,22, 137,4,196,27,248,22,137,4,248,22,68,195,249,22,130,4,80,158,39,35,28, -248,22,75,195,250,22,78,2,20,9,248,22,69,199,250,22,77,2,8,248,22, -77,248,22,68,199,250,22,78,2,11,248,22,69,201,248,22,69,202,27,248,22, +248,22,75,195,250,22,78,2,20,9,248,22,69,199,250,22,77,2,11,248,22, +77,248,22,68,199,250,22,78,2,5,248,22,69,201,248,22,69,202,27,248,22, 69,248,22,137,4,23,197,1,27,249,22,1,22,81,249,22,2,22,137,4,248, 22,137,4,248,22,68,199,249,22,130,4,80,158,39,35,251,22,77,1,22,119, 105,116,104,45,99,111,110,116,105,110,117,97,116,105,111,110,45,109,97,114,107, @@ -62,13 +62,13 @@ 28,248,22,75,193,20,15,159,36,35,36,249,22,130,4,80,158,38,35,27,248, 22,137,4,248,22,68,197,28,249,22,167,8,62,61,62,248,22,131,4,248,22, 92,196,250,22,77,2,20,248,22,77,249,22,77,21,93,2,25,248,22,68,199, -250,22,78,2,3,249,22,77,2,25,249,22,77,248,22,101,203,2,25,248,22, +250,22,78,2,8,249,22,77,2,25,249,22,77,248,22,101,203,2,25,248,22, 69,202,251,22,77,2,16,28,249,22,167,8,248,22,131,4,248,22,68,200,64, 101,108,115,101,10,248,22,68,197,250,22,78,2,20,9,248,22,69,200,249,22, -67,2,3,248,22,69,202,100,8,31,8,30,8,29,8,28,8,27,16,4,11, -11,2,18,3,1,8,101,110,118,49,48,50,52,57,16,4,11,11,2,19,3, -1,8,101,110,118,49,48,50,53,48,93,8,224,234,60,0,0,18,16,2,158, -94,10,64,118,111,105,100,8,47,95,9,8,224,234,60,0,0,2,1,27,248, +67,2,8,248,22,69,202,100,8,31,8,30,8,29,8,28,8,27,16,4,11, +11,2,18,3,1,8,101,110,118,49,48,51,52,52,16,4,11,11,2,19,3, +1,8,101,110,118,49,48,51,52,53,93,8,224,53,61,0,0,18,16,2,158, +94,10,64,118,111,105,100,8,47,95,9,8,224,53,61,0,0,2,1,27,248, 22,69,248,22,137,4,196,249,22,130,4,80,158,38,35,28,248,22,53,248,22, 131,4,248,22,68,197,250,22,77,2,26,248,22,77,248,22,68,199,248,22,92, 198,27,248,22,131,4,248,22,68,197,250,22,77,2,26,248,22,77,248,22,68, @@ -80,25 +80,25 @@ 11,11,11,11,11,11,11,16,10,2,3,2,4,2,5,2,6,2,7,2,8, 2,9,2,10,2,11,2,12,35,45,36,11,11,11,16,0,16,0,16,0,35, 35,11,11,11,11,16,0,16,0,16,0,35,35,16,11,16,5,2,2,20,15, -159,35,35,35,35,20,103,159,35,16,0,16,1,33,32,10,16,5,2,7,89, +159,35,35,35,35,20,103,159,35,16,0,16,1,33,32,10,16,5,2,10,89, 162,8,44,36,52,9,223,0,33,33,35,20,103,159,35,16,1,2,2,16,0, -11,16,5,2,10,89,162,8,44,36,52,9,223,0,33,34,35,20,103,159,35, -16,1,2,2,16,0,11,16,5,2,12,89,162,8,44,36,52,9,223,0,33, -35,35,20,103,159,35,16,1,2,2,16,1,33,36,11,16,5,2,4,89,162, +11,16,5,2,12,89,162,8,44,36,52,9,223,0,33,34,35,20,103,159,35, +16,1,2,2,16,0,11,16,5,2,4,89,162,8,44,36,52,9,223,0,33, +35,35,20,103,159,35,16,1,2,2,16,1,33,36,11,16,5,2,7,89,162, 8,44,36,55,9,223,0,33,37,35,20,103,159,35,16,1,2,2,16,1,33, -38,11,16,5,2,8,89,162,8,44,36,57,9,223,0,33,41,35,20,103,159, -35,16,1,2,2,16,0,11,16,5,2,5,89,162,8,44,36,52,9,223,0, -33,43,35,20,103,159,35,16,1,2,2,16,0,11,16,5,2,11,89,162,8, +38,11,16,5,2,11,89,162,8,44,36,57,9,223,0,33,41,35,20,103,159, +35,16,1,2,2,16,0,11,16,5,2,9,89,162,8,44,36,52,9,223,0, +33,43,35,20,103,159,35,16,1,2,2,16,0,11,16,5,2,5,89,162,8, 44,36,53,9,223,0,33,44,35,20,103,159,35,16,1,2,2,16,0,11,16, 5,2,6,89,162,8,44,36,54,9,223,0,33,45,35,20,103,159,35,16,1, -2,2,16,0,11,16,5,2,3,89,162,8,44,36,57,9,223,0,33,46,35, -20,103,159,35,16,1,2,2,16,1,33,48,11,16,5,2,9,89,162,8,44, +2,2,16,0,11,16,5,2,8,89,162,8,44,36,57,9,223,0,33,46,35, +20,103,159,35,16,1,2,2,16,1,33,48,11,16,5,2,3,89,162,8,44, 36,53,9,223,0,33,49,35,20,103,159,35,16,1,2,2,16,0,11,16,0, 94,2,14,2,15,93,2,14,9,9,35,0}; EVAL_ONE_SIZED_STR((char *)expr, 2006); } { - static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,50,46,48,46,54,59,0,0,0,1,0,0,13,0,18,0, + static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,50,46,49,46,53,59,0,0,0,1,0,0,13,0,18,0, 35,0,50,0,68,0,84,0,94,0,112,0,132,0,148,0,166,0,197,0,226, 0,248,0,6,1,12,1,26,1,31,1,41,1,49,1,77,1,109,1,154,1, 199,1,223,1,6,2,8,2,65,2,155,3,196,3,31,5,135,5,239,5,100, @@ -134,20 +134,20 @@ 22,157,6,23,194,2,12,87,94,248,22,171,8,23,194,1,248,80,159,37,53, 36,195,28,248,22,75,23,195,2,9,27,248,22,68,23,196,2,27,28,248,22, 170,13,23,195,2,23,194,1,28,248,22,169,13,23,195,2,249,22,171,13,23, -196,1,250,80,158,42,48,248,22,185,13,2,19,11,10,250,80,158,40,48,248, -22,185,13,2,19,23,197,1,10,28,23,193,2,249,22,67,248,22,173,13,249, -22,171,13,23,198,1,247,22,186,13,27,248,22,69,23,200,1,28,248,22,75, +196,1,250,80,158,42,48,248,22,186,13,2,19,11,10,250,80,158,40,48,248, +22,186,13,2,19,23,197,1,10,28,23,193,2,249,22,67,248,22,173,13,249, +22,171,13,23,198,1,247,22,187,13,27,248,22,69,23,200,1,28,248,22,75, 23,194,2,9,27,248,22,68,23,195,2,27,28,248,22,170,13,23,195,2,23, 194,1,28,248,22,169,13,23,195,2,249,22,171,13,23,196,1,250,80,158,47, -48,248,22,185,13,2,19,11,10,250,80,158,45,48,248,22,185,13,2,19,23, +48,248,22,186,13,2,19,11,10,250,80,158,45,48,248,22,186,13,2,19,23, 197,1,10,28,23,193,2,249,22,67,248,22,173,13,249,22,171,13,23,198,1, -247,22,186,13,248,80,159,45,52,36,248,22,69,23,199,1,87,94,23,193,1, +247,22,187,13,248,80,159,45,52,36,248,22,69,23,199,1,87,94,23,193,1, 248,80,159,43,52,36,248,22,69,23,197,1,87,94,23,193,1,27,248,22,69, 23,198,1,28,248,22,75,23,194,2,9,27,248,22,68,23,195,2,27,28,248, 22,170,13,23,195,2,23,194,1,28,248,22,169,13,23,195,2,249,22,171,13, -23,196,1,250,80,158,45,48,248,22,185,13,2,19,11,10,250,80,158,43,48, -248,22,185,13,2,19,23,197,1,10,28,23,193,2,249,22,67,248,22,173,13, -249,22,171,13,23,198,1,247,22,186,13,248,80,159,43,52,36,248,22,69,23, +23,196,1,250,80,158,45,48,248,22,186,13,2,19,11,10,250,80,158,43,48, +248,22,186,13,2,19,23,197,1,10,28,23,193,2,249,22,67,248,22,173,13, +249,22,171,13,23,198,1,247,22,187,13,248,80,159,43,52,36,248,22,69,23, 199,1,248,80,159,41,52,36,248,22,69,196,27,248,22,146,13,23,195,2,28, 23,193,2,192,87,94,23,193,1,28,248,22,162,6,23,195,2,27,248,22,168, 13,195,28,192,192,248,22,169,13,195,11,87,94,28,28,248,22,147,13,23,195, @@ -159,12 +159,12 @@ 97,108,105,100,45,112,97,116,104,32,115,116,114,105,110,103,23,197,2,28,28, 248,22,147,13,23,195,2,249,22,167,8,248,22,148,13,23,197,2,2,20,249, 22,167,8,247,22,181,7,2,20,27,28,248,22,162,6,23,196,2,23,195,2, -248,22,171,7,248,22,151,13,23,197,2,28,249,22,134,14,0,21,35,114,120, +248,22,171,7,248,22,151,13,23,197,2,28,249,22,135,14,0,21,35,114,120, 34,94,91,92,92,93,91,92,92,93,91,63,93,91,92,92,93,34,23,195,2, 28,248,22,162,6,195,248,22,154,13,195,194,27,248,22,137,7,23,195,1,249, -22,155,13,248,22,174,7,250,22,140,14,0,6,35,114,120,34,47,34,28,249, -22,134,14,0,22,35,114,120,34,91,47,92,92,93,91,46,32,93,43,91,47, -92,92,93,42,36,34,23,201,2,23,199,1,250,22,140,14,0,19,35,114,120, +22,155,13,248,22,174,7,250,22,141,14,0,6,35,114,120,34,47,34,28,249, +22,135,14,0,22,35,114,120,34,91,47,92,92,93,91,46,32,93,43,91,47, +92,92,93,42,36,34,23,201,2,23,199,1,250,22,141,14,0,19,35,114,120, 34,91,32,46,93,43,40,91,47,92,92,93,42,41,36,34,23,202,1,6,2, 2,92,49,80,159,43,36,37,2,20,28,248,22,162,6,194,248,22,154,13,194, 193,87,94,28,27,248,22,146,13,23,196,2,28,23,193,2,192,87,94,23,193, @@ -202,7 +202,7 @@ 1,250,22,1,22,164,13,23,206,1,23,207,1,23,200,1,27,249,22,164,13, 248,22,68,23,197,2,23,201,2,28,248,22,159,13,23,194,2,27,250,22,1, 22,164,13,23,197,1,203,28,248,22,159,13,193,192,253,2,37,202,203,204,205, -206,248,22,69,201,253,2,37,201,202,203,204,205,248,22,69,200,27,247,22,187, +206,248,22,69,201,253,2,37,201,202,203,204,205,248,22,69,200,27,247,22,188, 13,253,2,37,198,199,200,201,202,198,87,95,28,28,248,22,147,13,23,194,2, 10,27,248,22,146,13,23,195,2,28,23,193,2,192,87,94,23,193,1,28,248, 22,162,6,23,195,2,27,248,22,168,13,23,196,2,28,23,193,2,192,87,94, @@ -219,7 +219,7 @@ 22,150,7,23,197,2,12,252,22,135,9,2,9,2,25,36,23,200,2,23,201, 2,91,159,38,11,90,161,38,35,11,248,22,167,13,23,199,2,87,94,23,195, 1,87,94,28,192,12,250,22,136,9,2,9,2,26,23,201,2,249,22,7,194, -195,27,249,22,156,13,250,22,139,14,0,20,35,114,120,35,34,40,63,58,91, +195,27,249,22,156,13,250,22,140,14,0,20,35,114,120,35,34,40,63,58,91, 46,93,91,94,46,93,42,124,41,36,34,248,22,152,13,23,201,1,28,248,22, 162,6,23,203,2,249,22,174,7,23,204,1,8,63,23,202,1,28,248,22,147, 13,23,199,2,248,22,148,13,23,199,1,87,94,23,198,1,247,22,149,13,28, @@ -231,21 +231,21 @@ 162,6,23,197,2,10,248,22,150,7,23,197,2,12,252,22,135,9,2,10,2, 25,36,23,200,2,23,201,2,91,159,38,11,90,161,38,35,11,248,22,167,13, 23,199,2,87,94,23,195,1,87,94,28,192,12,250,22,136,9,2,10,2,26, -23,201,2,249,22,7,194,195,27,249,22,156,13,249,22,160,7,250,22,140,14, +23,201,2,249,22,7,194,195,27,249,22,156,13,249,22,160,7,250,22,141,14, 0,9,35,114,120,35,34,91,46,93,34,248,22,152,13,23,203,1,6,1,1, 95,28,248,22,162,6,23,202,2,249,22,174,7,23,203,1,8,63,23,201,1, 28,248,22,147,13,23,199,2,248,22,148,13,23,199,1,87,94,23,198,1,247, 22,149,13,28,248,22,146,13,194,249,22,164,13,195,194,192,249,247,22,129,5, 194,11,249,80,159,37,46,36,9,9,249,80,159,37,46,36,195,9,27,247,22, -189,13,249,80,158,38,47,28,23,195,2,27,248,22,179,7,6,11,11,80,76, +190,13,249,80,158,38,47,28,23,195,2,27,248,22,179,7,6,11,11,80,76, 84,67,79,76,76,69,67,84,83,28,192,192,6,0,0,6,0,0,27,28,23, -196,1,250,22,164,13,248,22,185,13,69,97,100,100,111,110,45,100,105,114,247, +196,1,250,22,164,13,248,22,186,13,69,97,100,100,111,110,45,100,105,114,247, 22,177,7,6,8,8,99,111,108,108,101,99,116,115,11,27,248,80,159,41,52, -36,250,22,81,23,203,1,248,22,77,248,22,185,13,72,99,111,108,108,101,99, +36,250,22,81,23,203,1,248,22,77,248,22,186,13,72,99,111,108,108,101,99, 116,115,45,100,105,114,23,204,1,28,193,249,22,67,195,194,192,32,47,89,162, -8,44,38,54,2,18,222,33,48,27,249,22,132,14,23,197,2,23,198,2,28, +8,44,38,54,2,18,222,33,48,27,249,22,133,14,23,197,2,23,198,2,28, 23,193,2,87,94,23,196,1,27,248,22,92,23,195,2,27,27,248,22,101,23, -197,1,27,249,22,132,14,23,201,2,23,196,2,28,23,193,2,87,94,23,194, +197,1,27,249,22,133,14,23,201,2,23,196,2,28,23,193,2,87,94,23,194, 1,27,248,22,92,23,195,2,27,250,2,47,23,203,2,23,204,1,248,22,101, 23,199,1,28,249,22,156,7,23,196,2,2,27,249,22,81,23,202,2,194,249, 22,67,248,22,155,13,23,197,1,194,87,95,23,199,1,23,193,1,28,249,22, @@ -296,7 +296,7 @@ 80,159,38,48,36,196,197,11,250,80,159,38,48,36,196,11,11,87,94,249,22, 153,6,247,22,189,4,195,248,22,179,5,249,22,174,3,35,249,22,158,3,197, 198,27,28,23,197,2,87,95,23,196,1,23,195,1,23,197,1,87,94,23,197, -1,27,248,22,185,13,2,19,27,249,80,159,40,48,36,23,196,1,11,27,27, +1,27,248,22,186,13,2,19,27,249,80,159,40,48,36,23,196,1,11,27,27, 248,22,177,3,23,200,1,28,192,192,35,27,27,248,22,177,3,23,202,1,28, 192,192,35,249,22,156,5,23,197,1,83,158,39,20,97,95,89,162,8,44,35, 47,9,224,3,2,33,57,23,195,1,23,196,1,27,248,22,141,5,23,195,1, @@ -328,7 +328,7 @@ 11,222,33,43,80,159,35,45,36,83,158,35,16,2,83,158,38,20,96,96,2, 12,89,162,43,35,43,9,223,0,33,44,89,162,43,36,44,9,223,0,33,45, 89,162,43,37,54,9,223,0,33,46,80,159,35,46,36,83,158,35,16,2,27, -248,22,128,14,248,22,173,7,27,28,249,22,167,8,247,22,181,7,2,20,6, +248,22,129,14,248,22,173,7,27,28,249,22,167,8,247,22,181,7,2,20,6, 1,1,59,6,1,1,58,250,22,146,7,6,14,14,40,91,94,126,97,93,42, 41,126,97,40,46,42,41,23,196,2,23,196,1,89,162,8,44,37,47,2,13, 223,0,33,49,80,159,35,47,36,83,158,35,16,2,83,158,38,20,96,96,2, @@ -340,12 +340,12 @@ EVAL_ONE_SIZED_STR((char *)expr, 5006); } { - static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,50,46,48,46,54,8,0,0,0,1,0,0,6,0,19,0, + static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,50,46,49,46,53,8,0,0,0,1,0,0,6,0,19,0, 34,0,48,0,62,0,76,0,115,0,0,0,6,1,0,0,65,113,117,111,116, 101,29,94,2,1,67,35,37,117,116,105,108,115,11,29,94,2,1,69,35,37, 110,101,116,119,111,114,107,11,29,94,2,1,68,35,37,112,97,114,97,109,122, 11,29,94,2,1,68,35,37,101,120,112,111,98,115,11,29,94,2,1,68,35, -37,107,101,114,110,101,108,11,97,35,11,8,166,245,98,159,2,2,35,35,159, +37,107,101,114,110,101,108,11,97,35,11,8,177,246,98,159,2,2,35,35,159, 2,3,35,35,159,2,4,35,35,159,2,5,35,35,159,2,6,35,35,159,2, 6,35,35,16,0,159,35,20,103,159,35,16,1,11,16,0,83,158,41,20,100, 144,69,35,37,98,117,105,108,116,105,110,29,11,11,11,11,11,18,96,11,42, @@ -358,7 +358,7 @@ EVAL_ONE_SIZED_STR((char *)expr, 299); } { - static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,50,46,48,46,54,52,0,0,0,1,0,0,11,0,38,0, + static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,50,46,49,46,53,52,0,0,0,1,0,0,11,0,38,0, 44,0,57,0,71,0,93,0,119,0,131,0,149,0,169,0,181,0,197,0,220, 0,0,1,5,1,10,1,15,1,24,1,29,1,60,1,64,1,72,1,81,1, 89,1,192,1,237,1,1,2,30,2,61,2,117,2,127,2,174,2,184,2,191, @@ -385,16 +385,16 @@ 28,248,22,146,13,23,194,2,91,159,38,11,90,161,38,35,11,248,22,167,13, 23,197,1,87,95,83,160,37,11,80,158,40,46,198,83,160,37,11,80,158,40, 47,192,192,11,11,28,23,193,2,192,87,94,23,193,1,27,247,22,130,5,28, -192,192,247,22,186,13,20,14,159,80,158,35,39,250,80,158,38,40,249,22,27, +192,192,247,22,187,13,20,14,159,80,158,35,39,250,80,158,38,40,249,22,27, 11,80,158,40,39,22,130,5,28,248,22,146,13,23,198,2,23,197,1,87,94, -23,197,1,247,22,186,13,247,194,250,22,164,13,23,197,1,23,199,1,249,80, +23,197,1,247,22,187,13,247,194,250,22,164,13,23,197,1,23,199,1,249,80, 158,42,38,23,198,1,2,17,252,22,164,13,23,199,1,23,201,1,2,18,247, 22,182,7,249,80,158,44,38,23,200,1,80,159,44,35,37,87,94,23,194,1, 27,250,22,181,13,196,11,32,0,89,162,8,44,35,40,9,222,11,28,192,249, 22,67,195,194,11,27,252,22,164,13,23,200,1,23,202,1,2,18,247,22,182, 7,249,80,158,45,38,23,201,1,80,159,45,35,37,27,250,22,181,13,196,11, 32,0,89,162,8,44,35,40,9,222,11,28,192,249,22,67,195,194,11,249,247, -22,191,13,248,22,68,195,195,27,250,22,164,13,23,198,1,23,200,1,249,80, +22,128,14,248,22,68,195,195,27,250,22,164,13,23,198,1,23,200,1,249,80, 158,43,38,23,199,1,2,17,27,250,22,181,13,196,11,32,0,89,162,8,44, 35,40,9,222,11,28,192,249,22,67,195,194,11,249,247,22,128,5,248,22,68, 195,195,249,247,22,128,5,194,195,87,94,28,248,80,158,36,37,23,195,2,12, @@ -405,7 +405,7 @@ 171,13,23,203,1,23,195,1,200,90,161,38,36,11,248,22,167,13,23,194,2, 87,94,23,196,1,90,161,36,39,11,28,249,22,167,8,23,196,2,68,114,101, 108,97,116,105,118,101,87,94,23,194,1,2,16,23,194,1,90,161,36,40,11, -247,22,188,13,27,89,162,43,36,49,62,122,111,225,7,5,3,33,27,27,89, +247,22,189,13,27,89,162,43,36,49,62,122,111,225,7,5,3,33,27,27,89, 162,43,36,51,9,225,8,6,4,33,28,27,249,22,5,89,162,8,44,36,46, 9,223,5,33,29,23,203,2,27,28,23,195,1,27,249,22,5,89,162,8,44, 36,52,9,225,13,11,9,33,30,23,205,2,27,28,23,196,2,11,193,28,192, @@ -418,10 +418,10 @@ 203,89,162,43,35,45,9,224,15,2,33,33,249,80,159,48,54,36,203,89,162, 43,35,44,9,224,15,7,33,34,32,36,89,162,8,44,36,54,2,19,222,33, 38,0,17,35,114,120,34,94,40,46,42,63,41,47,40,46,42,41,36,34,27, -249,22,132,14,2,37,23,196,2,28,23,193,2,87,94,23,194,1,249,22,67, -248,22,92,23,196,2,27,248,22,101,23,197,1,27,249,22,132,14,2,37,23, +249,22,133,14,2,37,23,196,2,28,23,193,2,87,94,23,194,1,249,22,67, +248,22,92,23,196,2,27,248,22,101,23,197,1,27,249,22,133,14,2,37,23, 196,2,28,23,193,2,87,94,23,194,1,249,22,67,248,22,92,23,196,2,27, -248,22,101,23,197,1,27,249,22,132,14,2,37,23,196,2,28,23,193,2,87, +248,22,101,23,197,1,27,249,22,133,14,2,37,23,196,2,28,23,193,2,87, 94,23,194,1,249,22,67,248,22,92,23,196,2,248,2,36,248,22,101,23,197, 1,248,22,77,194,248,22,77,194,248,22,77,194,32,39,89,162,43,36,54,2, 19,222,33,40,28,248,22,75,248,22,69,23,195,2,249,22,7,9,248,22,68, @@ -434,9 +434,9 @@ 192,248,2,39,193,87,95,28,248,22,174,4,195,12,250,22,135,9,2,20,6, 20,20,114,101,115,111,108,118,101,100,45,109,111,100,117,108,101,45,112,97,116, 104,197,28,24,193,2,248,24,194,1,195,87,94,23,193,1,12,27,27,250,22, -141,2,80,159,41,42,37,248,22,152,14,247,22,129,12,11,28,23,193,2,192, +141,2,80,159,41,42,37,248,22,153,14,247,22,129,12,11,28,23,193,2,192, 87,94,23,193,1,27,247,22,125,87,94,250,22,139,2,80,159,42,42,37,248, -22,152,14,247,22,129,12,195,192,250,22,139,2,195,198,66,97,116,116,97,99, +22,153,14,247,22,129,12,195,192,250,22,139,2,195,198,66,97,116,116,97,99, 104,251,211,197,198,199,10,28,192,250,22,134,9,11,196,195,248,22,132,9,194, 28,249,22,168,6,194,6,1,1,46,2,16,28,249,22,168,6,194,6,2,2, 46,46,62,117,112,192,28,249,22,169,8,248,22,69,23,200,2,23,197,1,28, @@ -444,7 +444,7 @@ 26,99,121,99,108,101,32,105,110,32,108,111,97,100,105,110,103,32,97,116,32, 126,101,58,32,126,101,23,200,1,249,22,2,22,69,248,22,82,249,22,67,23, 206,1,23,202,1,12,12,247,192,20,14,159,80,159,39,44,37,249,22,67,248, -22,152,14,247,22,129,12,23,197,1,20,14,159,80,158,39,39,250,80,158,42, +22,153,14,247,22,129,12,23,197,1,20,14,159,80,158,39,39,250,80,158,42, 40,249,22,27,11,80,158,44,39,22,156,4,23,196,1,249,247,22,129,5,23, 198,1,248,22,55,248,22,150,13,23,198,1,87,94,28,28,248,22,146,13,23, 197,2,10,248,22,180,4,23,197,2,12,28,23,198,2,250,22,134,9,11,6, @@ -460,7 +460,7 @@ 109,101,45,114,101,115,111,108,118,101,114,12,251,211,199,200,201,202,87,94,23, 193,1,27,89,162,8,44,36,45,79,115,104,111,119,45,99,111,108,108,101,99, 116,105,111,110,45,101,114,114,223,6,33,44,27,28,248,22,53,23,199,2,27, -250,22,141,2,80,159,43,43,37,249,22,67,23,204,2,247,22,187,13,11,28, +250,22,141,2,80,159,43,43,37,249,22,67,23,204,2,247,22,188,13,11,28, 23,193,2,192,87,94,23,193,1,91,159,37,11,90,161,37,35,11,249,80,159, 44,48,36,248,22,58,23,204,2,11,27,251,80,158,47,50,2,20,23,202,1, 28,248,22,75,23,199,2,23,199,2,248,22,68,23,199,2,28,248,22,75,23, @@ -475,17 +475,17 @@ 94,23,194,1,28,248,22,169,13,23,199,2,23,198,2,248,22,77,6,26,26, 32,40,97,32,112,97,116,104,32,109,117,115,116,32,98,101,32,97,98,115,111, 108,117,116,101,41,28,249,22,167,8,248,22,68,23,201,2,2,21,27,250,22, -141,2,80,159,43,43,37,249,22,67,23,204,2,247,22,187,13,11,28,23,193, +141,2,80,159,43,43,37,249,22,67,23,204,2,247,22,188,13,11,28,23,193, 2,192,87,94,23,193,1,91,159,38,11,90,161,37,35,11,249,80,159,45,48, 36,248,22,92,23,205,2,11,90,161,36,37,11,28,248,22,75,248,22,94,23, -204,2,28,248,22,75,23,194,2,249,22,134,14,0,8,35,114,120,34,91,46, +204,2,28,248,22,75,23,194,2,249,22,135,14,0,8,35,114,120,34,91,46, 93,34,23,196,2,11,10,27,27,28,23,197,2,249,22,81,28,248,22,75,248, 22,94,23,208,2,21,93,6,5,5,109,122,108,105,98,249,22,1,22,81,249, 22,2,80,159,51,56,36,248,22,94,23,211,2,23,197,2,28,248,22,75,23, 196,2,248,22,77,23,197,2,23,195,2,251,80,158,49,50,2,20,23,204,1, 248,22,68,23,198,2,248,22,69,23,198,1,249,22,164,13,23,195,1,28,23, 198,1,87,94,23,196,1,23,197,1,28,248,22,75,23,197,1,87,94,23,197, -1,6,7,7,109,97,105,110,46,115,115,28,249,22,134,14,0,8,35,114,120, +1,6,7,7,109,97,105,110,46,115,115,28,249,22,135,14,0,8,35,114,120, 34,91,46,93,34,23,199,2,23,197,1,249,22,185,6,23,199,1,6,3,3, 46,115,115,28,249,22,167,8,248,22,68,23,201,2,64,102,105,108,101,249,22, 171,13,248,22,175,13,248,22,92,23,202,2,248,80,159,42,55,36,23,202,2, @@ -503,11 +503,11 @@ 28,248,22,184,7,23,200,2,249,22,189,7,23,201,2,38,249,80,158,47,52, 23,197,2,5,0,27,28,248,22,184,7,23,201,2,249,22,189,7,23,202,2, 39,248,22,175,4,23,200,2,27,27,250,22,141,2,80,159,51,42,37,248,22, -152,14,247,22,129,12,11,28,23,193,2,192,87,94,23,193,1,27,247,22,125, -87,94,250,22,139,2,80,159,52,42,37,248,22,152,14,247,22,129,12,195,192, +153,14,247,22,129,12,11,28,23,193,2,192,87,94,23,193,1,27,247,22,125, +87,94,250,22,139,2,80,159,52,42,37,248,22,153,14,247,22,129,12,195,192, 87,95,28,23,209,1,27,250,22,141,2,23,197,2,197,11,28,23,193,1,12, 87,95,27,27,28,248,22,17,80,159,51,45,37,80,159,50,45,37,247,22,19, -250,22,25,248,22,23,23,197,2,80,159,53,44,37,23,196,1,27,248,22,152, +250,22,25,248,22,23,23,197,2,80,159,53,44,37,23,196,1,27,248,22,153, 14,247,22,129,12,249,22,3,83,158,39,20,97,94,89,162,8,44,36,54,9, 226,12,11,2,3,33,46,23,195,1,23,196,1,248,28,248,22,17,80,159,50, 45,37,32,0,89,162,43,36,41,9,222,33,47,80,159,49,57,36,89,162,43, @@ -516,7 +516,7 @@ 27,248,22,53,23,209,2,28,192,192,28,248,22,65,23,209,2,249,22,167,8, 248,22,68,23,211,2,2,21,11,250,22,139,2,80,159,50,43,37,28,248,22, 162,6,23,210,2,249,22,67,23,211,1,248,80,159,53,55,36,23,213,1,87, -94,23,210,1,249,22,67,23,211,1,247,22,187,13,252,22,186,7,23,208,1, +94,23,210,1,249,22,67,23,211,1,247,22,188,13,252,22,186,7,23,208,1, 23,207,1,23,205,1,23,203,1,201,12,193,91,159,37,10,90,161,36,35,10, 11,90,161,36,36,10,83,158,38,20,96,96,2,20,89,162,8,44,36,50,9, 224,2,0,33,42,89,162,43,38,48,9,223,1,33,43,89,162,43,39,8,30, diff --git a/src/mzscheme/src/file.c b/src/mzscheme/src/file.c index b7949a594e..bc14d2cc20 100644 --- a/src/mzscheme/src/file.c +++ b/src/mzscheme/src/file.c @@ -195,6 +195,7 @@ static Scheme_Object *expand_user_path(int argc, Scheme_Object *argv[]); static Scheme_Object *current_drive(int argc, Scheme_Object *argv[]); static Scheme_Object *file_modify_seconds(int argc, Scheme_Object *argv[]); static Scheme_Object *file_or_dir_permissions(int argc, Scheme_Object *argv[]); +static Scheme_Object *file_identity(int argc, Scheme_Object *argv[]); static Scheme_Object *file_size(int argc, Scheme_Object *argv[]); static Scheme_Object *current_library_collection_paths(int argc, Scheme_Object *argv[]); static Scheme_Object *use_compiled_kind(int, Scheme_Object *[]); @@ -474,6 +475,11 @@ void scheme_init_file(Scheme_Env *env) "file-or-directory-permissions", 1, 1), env); + scheme_add_global_constant("file-or-directory-identity", + scheme_make_prim_w_arity(file_identity, + "file-or-directory-identity", + 1, 2), + env); scheme_add_global_constant("file-size", scheme_make_prim_w_arity(file_size, "file-size", @@ -2311,7 +2317,8 @@ static Scheme_Object *link_exists(int argc, Scheme_Object **argv) #endif } -Scheme_Object *scheme_get_fd_identity(Scheme_Object *port, long fd) +Scheme_Object *scheme_get_fd_identity(Scheme_Object *port, long fd, char *path) +/* If path is supplied, then fd is 0 for stat, 1 for lstat */ { int errid = 0; unsigned long devi = 0, inoi = 0, inoi2 = 0; @@ -2322,7 +2329,11 @@ Scheme_Object *scheme_get_fd_identity(Scheme_Object *port, long fd) struct MSC_IZE(stat) buf; while (1) { - if (!MSC_IZE(fstat)(fd, &buf)) + if (!path && !MSC_IZE(fstat)(fd, &buf)) + break; + else if (path && !fd && !MSC_IZE(stat)(path, &buf)) + break; + else if (path && fd && !MSC_IZE(lstat)(path, &buf)) break; else if (errno != EINTR) { errid = errno; @@ -2340,10 +2351,29 @@ Scheme_Object *scheme_get_fd_identity(Scheme_Object *port, long fd) #ifdef WINDOWS_FILE_HANDLES BY_HANDLE_FILE_INFORMATION info; - if (GetFileInformationByHandle((HANDLE)fd, &info)) - errid = 0; - else - errid = GetLastError(); + errid = 0; + if (path) { + fd = CreateFileW(WIDE_PATH(path), + 0, /* not even read access => just get info */ + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + 0, + NULL); + if (fd == INVALID_HANDLE_VALUE) { + errid = GetLastError(); + } + } + + if (fd == INVALID_HANDLE_VALUE) { + /* errid is set */ + } else { + if (!GetFileInformationByHandle((HANDLE)fd, &info)) + errid = GetLastError(); + + if (path) + CloseHandle(fd); + } if (!errid) { devi = info.dwVolumeSerialNumber; @@ -2371,9 +2401,17 @@ Scheme_Object *scheme_get_fd_identity(Scheme_Object *port, long fd) return scheme_bin_plus(devn, inon); } - scheme_raise_exn(MZEXN_FAIL_FILESYSTEM, - "port-file-identity: error obtaining identity (%E)", - errid); + if (!path) { + scheme_raise_exn(MZEXN_FAIL_FILESYSTEM, + "port-file-identity: error obtaining identity (%E)", + errid); + } else { + scheme_raise_exn(MZEXN_FAIL_FILESYSTEM, + "file-or-directory-identity: error obtaining identity for \"%q\" (%E)", + path, + errid); + } + return NULL; } @@ -5431,6 +5469,25 @@ static Scheme_Object *file_or_dir_permissions(int argc, Scheme_Object *argv[]) return l; } +static Scheme_Object *file_identity(int argc, Scheme_Object *argv[]) +{ + char *filename; + int as_link = 0; + + if (!SCHEME_PATH_STRINGP(argv[0])) + scheme_wrong_type("file-or-directory-identity", SCHEME_PATH_STRING_STR, 0, argc, argv); + + filename = scheme_expand_string_filename(argv[0], + "file-or-directory-identity", + NULL, + SCHEME_GUARD_FILE_EXISTS); + + if (argc > 1) + as_link = SCHEME_TRUEP(argv[1]); + + return scheme_get_fd_identity(NULL, as_link, filename); +} + static Scheme_Object *file_size(int argc, Scheme_Object *argv[]) { char *filename; diff --git a/src/mzscheme/src/port.c b/src/mzscheme/src/port.c index 4723887596..b9b6522bdd 100644 --- a/src/mzscheme/src/port.c +++ b/src/mzscheme/src/port.c @@ -3701,7 +3701,7 @@ Scheme_Object *scheme_file_identity(int argc, Scheme_Object *argv[]) return NULL; } - return scheme_get_fd_identity(p, fd); + return scheme_get_fd_identity(p, fd, NULL); } static int is_fd_terminal(int fd) diff --git a/src/mzscheme/src/schminc.h b/src/mzscheme/src/schminc.h index 172e54dc25..0b1eb0e92c 100644 --- a/src/mzscheme/src/schminc.h +++ b/src/mzscheme/src/schminc.h @@ -13,7 +13,7 @@ #define USE_COMPILED_STARTUP 1 -#define EXPECTED_PRIM_COUNT 957 +#define EXPECTED_PRIM_COUNT 958 #ifdef MZSCHEME_SOMETHING_OMITTED # undef USE_COMPILED_STARTUP diff --git a/src/mzscheme/src/schpriv.h b/src/mzscheme/src/schpriv.h index ab03c1b7e0..c707497020 100644 --- a/src/mzscheme/src/schpriv.h +++ b/src/mzscheme/src/schpriv.h @@ -2968,7 +2968,7 @@ int scheme_is_special_filename(const char *_f, int not_nul); char *scheme_get_exec_path(void); Scheme_Object *scheme_get_run_cmd(void); -Scheme_Object *scheme_get_fd_identity(Scheme_Object *port, long fd); +Scheme_Object *scheme_get_fd_identity(Scheme_Object *port, long fd, char *path); Scheme_Object *scheme_extract_relative_to(Scheme_Object *obj, Scheme_Object *dir); diff --git a/src/mzscheme/src/schvers.h b/src/mzscheme/src/schvers.h index c9b3fd48b5..5082458341 100644 --- a/src/mzscheme/src/schvers.h +++ b/src/mzscheme/src/schvers.h @@ -13,12 +13,12 @@ consistently.) */ -#define MZSCHEME_VERSION "4.2.1.4" +#define MZSCHEME_VERSION "4.2.1.5" #define MZSCHEME_VERSION_X 4 #define MZSCHEME_VERSION_Y 2 #define MZSCHEME_VERSION_Z 1 -#define MZSCHEME_VERSION_W 4 +#define MZSCHEME_VERSION_W 5 #define MZSCHEME_VERSION_MAJOR ((MZSCHEME_VERSION_X * 100) + MZSCHEME_VERSION_Y) #define MZSCHEME_VERSION_MINOR ((MZSCHEME_VERSION_Z * 1000) + MZSCHEME_VERSION_W)