I have a function called ``older-than-days?'' which produces true if a
path is older than a number of days.  (Source code at the end of the
message.)

rac...@util.rkt> (older-than-days? 30 "c:/autoexec.bat")
#t

On Windows, if I give it a non-existent file, I can't seem to get an
errno set to ENOENT.

--8<---------------cut here---------------start------------->8---
rac...@util.rkt> (older-than-days? 30 "c:/whatever")
file-or-directory-modify-seconds: error getting file/directory time
  path: c:/whatever
  system error: Unknown error; errno=-1
#f
rac...@util.rkt>
--8<---------------cut here---------------end--------------->8---

I looked at the source code for file-or-directory-modify-seconds at

  
https://github.com/racket/racket/blob/136ea767e2f76aa3785ebd1ca214411cc68b4533/racket/src/rktio/rktio_fs.c#L1034

Here's the relevant passage:

--8<---------------cut here---------------start------------->8---
rktio_timestamp_t *rktio_get_file_modify_seconds(rktio_t *rktio, const char 
*file)
{
#ifdef RKTIO_SYSTEM_WINDOWS
  rktio_timestamp_t *secs;
  if (UNC_stat(rktio, file, NULL, NULL, NULL, &secs, NULL, NULL, -1))
    return secs;
  return NULL;
#else
 [...]
#endif
--8<---------------cut here---------------end--------------->8---

(I couldn't locate UNC_stat.  Where is it?)  I guessed it some stat()
C function was called.  Microsoft seems to say stat does set errno in
cases such as ENOENT.

  
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions?view=vs-2019

So I expected to see errno set to ENOENT in that example above.

Can you educate me on this?  Thank you.

--8<---------------cut here---------------start------------->8---
My ``older-than-days?'' source code:

(define (older-than-days? days path)
  (define timeline-mark (- (current-seconds) (* days 24 3600)))
  (define path-mark
    (with-handlers
        ([exn:fail:filesystem?
          (lambda (e) ;; where's my errno?
            (displayln (exn-message e))
            +inf.0)])
      (file-or-directory-modify-seconds path)))
  (< path-mark timeline-mark))
--8<---------------cut here---------------end--------------->8---

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/lwnybyElykkp86XSbAc727heWInydkLJUXrd65QEXw1OMznXm0sEQBwoHJV9e5hpA2N4sX5uoODUptUhmCGHHZIv7hqWZtwFCB1lUSDDzJQ%3D%40protonmail.com.

Reply via email to