- Timestamp:
- Jun 2, 2008, 8:28:05 AM (16 years ago)
- File:
-
- 1 edited
-
branches/win64/level-1/linux-files.lisp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/win64/level-1/linux-files.lisp
r9647 r9657 1279 1279 #+windows-target 1280 1280 (progn 1281 (defun temp-file-name (prefix) 1282 "Returns a unique name for a temporary file, residing in system temp 1283 space, and prefixed with PREFIX." 1284 (rlet ((buffer (:array :wchar_t #.#$MAX_PATH))) 1285 (#_GetTempPathW #$MAX_PATH buffer) 1286 (with-filename-cstrs ((c-prefix prefix)) 1287 (#_GetTempFileNameW buffer c-prefix 0 buffer) 1288 (%get-native-utf-16-cstring buffer)))) 1289 1281 1290 (defun get-descriptor-for (object proc close-in-parent close-on-error 1282 1291 &rest keys &key direction (element-type 'character) … … 1337 1346 (ecase direction 1338 1347 (:input 1339 (with-cstrs ((template "lisp-tempXXXXXX")) 1340 (let* ((fd (#_mktemp template))) 1341 (if (< fd 0) 1342 (%errno-disp fd)) 1343 (#_unlink template) 1344 (loop 1345 (multiple-value-bind (line no-newline) 1346 (read-line object nil nil) 1347 (unless line 1348 (return)) 1349 (let* ((len (length line))) 1350 (%stack-block ((buf (1+ len))) 1351 (%cstr-pointer line buf) 1352 (fd-write fd buf len) 1353 (if no-newline 1354 (return)) 1355 (setf (%get-byte buf) (char-code #\newline)) 1356 (fd-write fd buf 1))))) 1357 (fd-lseek fd 0 #$SEEK_SET) 1358 (values fd nil (cons fd close-in-parent) (cons fd close-on-error))))) 1348 (let* ((tempname (temp-file-name "lisp-temp")) 1349 (fd (fd-open tempname #$O_RDWR))) 1350 (if (< fd 0) 1351 (%errno-disp fd)) 1352 (loop 1353 (multiple-value-bind (line no-newline) 1354 (read-line object nil nil) 1355 (unless line 1356 (return)) 1357 (let* ((len (length line))) 1358 (%stack-block ((buf (1+ len))) 1359 (%cstr-pointer line buf) 1360 (fd-write fd buf len) 1361 (if no-newline 1362 (return)) 1363 (setf (%get-byte buf) (char-code #\newline)) 1364 (fd-write fd buf 1))))) 1365 (fd-lseek fd 0 #$SEEK_SET) 1366 (values fd nil (cons fd close-in-parent) (cons fd close-on-error)))) 1359 1367 (:output 1360 1368 (multiple-value-bind (read-pipe write-pipe) (pipe) … … 1385 1393 watched-stream 1386 1394 ) 1395 1396 (defun external-process-status (proc) 1397 "Return information about whether an OS subprocess is running; or, if 1398 not, why not; and what its result code was if it completed." 1399 (require-type proc 'external-process) 1400 (values (external-process-%status proc) 1401 (external-process-%exit-code proc))) 1402 1387 1403 1388 1404 (defmethod print-object ((p external-process) stream) … … 1462 1478 (dolist (fd close-on-error) (fd-close fd)) 1463 1479 (error "Process execution failed")))) 1464 (and (external-process-pid proc) proc)))1480 proc)) 1465 1481 1466 1482 (let* ((external-processes ()) … … 1492 1508 (signal-semaphore (external-process-signal proc)) 1493 1509 (monitor-external-process proc)) 1494 (error (condition) (signal-semaphore (external-process-signal proc))))) 1510 (error (condition) 1511 (setf (external-process-%status proc) :failed) 1512 (signal-semaphore (external-process-signal proc))))) 1495 1513 1496 1514 (defun join-strings (strings) … … 1538 1556 (if in-fd (fd-close in-fd)) 1539 1557 (setq in-fd nil) 1558 (rlet ((code #>DWORD)) 1559 (#_GetExitCodeProcess (external-process-pid p) code) 1560 (setf (external-process-%exit-code p) (pref code #>DWORD))) 1540 1561 (#_CloseHandle (external-process-pid p)) 1541 1562 (setf (external-process-pid p) nil)
Note:
See TracChangeset
for help on using the changeset viewer.
