Hello all!

I was trying to use mkstemp! in my program, instead of tmpnam, but I have no
success... I mkstemp! is getting me confused. It alters original string, so
we can easely have the name of temporary file.

But, with following code, I suposed it would work, but it is reusing an old
string:

#!/usr/bin/guile \
-s
!#

(define (test)
  (let ((filename "/tmp/XXXXXX")
        (tmp #f))
    (format #t "before: filename=~A\n" filename)
    (set! tmp (mkstemp! filename))
    (format #t "after : filename=~A\n" filename)
    (close tmp)))
          
(format #t "First call...\n")
(test)
(format #t "Second call...\n")
(test)
                          
And the result of this code is:

First call...
before: filename=/tmp/XXXXXX
after : filename=/tmp/HGLPtZ
Second call...
before: filename=/tmp/HGLPtZ
ERROR: In procedure mkstemp!:
ERROR: Invalid argument

I can not figure out why the string is not set to /tmp/XXXXXX in the second
call...

Some help!?

Regards
Betoes


_______________________________________________
Guile-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/guile-user

Reply via email to