Changeset 14176
- Timestamp:
- 10/11/12 11:33:19 (12 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/abcl/src/org/armedbear/lisp/Load.java ¶
r14029 r14176 141 141 mergedPathname = Pathname.mergePathnames(pathname, pathnameDefaults); 142 142 } 143 144 Pathname truename = findLoadableFile(mergedPathname != null ? mergedPathname : pathname);143 Pathname loadableFile = findLoadableFile(mergedPathname != null ? mergedPathname : pathname); 144 Pathname truename = coercePathnameOrNull(Pathname.truename(loadableFile)); 145 145 146 146 if (truename == null || truename.equals(NIL)) { … … 194 194 } 195 195 truename = (Pathname)initTruename; 196 } 197 196 } 197 198 198 InputStream in = truename.getInputStream(); 199 199 Debug.assertTrue(in != null); … … 250 250 static final LispObject COMPILE_FILE_INIT_FASL_TYPE = new SimpleString("_"); 251 251 252 private static final Pathname coercePathnameOrNull(LispObject p) { 253 if (p == null) { 254 return null; 255 } 256 Pathname result = null; 257 try { 258 result = (Pathname)p; 259 } catch (Throwable t) { // XXX narrow me! 260 return null; 261 } 262 return result; 263 } 264 265 252 266 public static final LispObject loadSystemFile(final String filename, 253 267 boolean verbose, … … 268 282 } 269 283 URL url = null; 270 truename = findLoadableFile(mergedPathname); 271 final String COMPILE_FILE_TYPE = Lisp._COMPILE_FILE_TYPE_.symbolValue().getStringValue(); 284 Pathname loadableFile = findLoadableFile(mergedPathname); 285 truename = coercePathnameOrNull(Pathname.truename(loadableFile)); 286 287 final String COMPILE_FILE_TYPE 288 = Lisp._COMPILE_FILE_TYPE_.symbolValue().getStringValue(); 289 272 290 if (truename == null || truename.equals(NIL) || bootPath.equals(NIL)) { 273 291 // Make an attempt to use the boot classpath … … 287 305 if (!bootPath.equals(NIL)) { 288 306 Pathname urlPathname = new Pathname(url); 289 truename = findLoadableFile(urlPathname); 307 loadableFile = findLoadableFile(urlPathname); 308 truename = (Pathname)Pathname.truename(loadableFile); 290 309 if (truename == null) { 291 310 return error(new LispError("Failed to find loadable system file in boot classpath " … … 482 501 Pathname truePathname = null; 483 502 if (!truename.equals(NIL)) { 484 truePathname = new Pathname(((Pathname)truename).getNamestring()); 503 if (truename instanceof Pathname) { 504 truePathname = new Pathname((Pathname)truename); 505 } else if (truename instanceof AbstractString) { 506 truePathname = new Pathname(truename.getStringValue()); 507 } else { 508 Debug.assertTrue(false); 509 } 485 510 String type = truePathname.type.getStringValue(); 486 511 if (type.equals(Lisp._COMPILE_FILE_TYPE_.symbolValue(thread).getStringValue()) -
TabularUnified trunk/abcl/src/org/armedbear/lisp/Pathname.java ¶
r14155 r14176 1 /* 1 /* 2 2 * Pathname.java 3 3 * … … 1640 1640 if (file.isDirectory()) { 1641 1641 if (arg2 != NIL) { 1642 p = Utilities.getDirectoryPathname(file);1642 p = Pathname.getDirectoryPathname(file); 1643 1643 } else { 1644 1644 p = new Pathname(file.getAbsolutePath()); … … 1916 1916 } 1917 1917 1918 privatestatic final Primitive MERGE_PATHNAMES = new pf_merge_pathnames();1918 static final Primitive MERGE_PATHNAMES = new pf_merge_pathnames(); 1919 1919 @DocString(name="merge-pathnames", 1920 1920 args="pathname &optional default-pathname default-version", … … 2115 2115 } 2116 2116 2117 2117 2118 public static final LispObject truename(Pathname pathname) { 2118 2119 return truename(pathname, false); … … 2135 2136 boolean errorIfDoesNotExist) 2136 2137 { 2138 if (pathname == null || pathname.equals(NIL)) { // XXX duplicates code at the end of this longish function: figure out proper nesting of labels. 2139 if (errorIfDoesNotExist) { 2140 StringBuilder sb = new StringBuilder("The file "); 2141 sb.append(pathname.princToString()); 2142 sb.append(" does not exist."); 2143 return error(new FileError(sb.toString(), pathname)); 2144 } 2145 return NIL; 2146 } 2137 2147 if (pathname instanceof LogicalPathname) { 2138 2148 pathname = LogicalPathname.translateLogicalPathname((LogicalPathname) pathname); … … 2143 2153 } 2144 2154 if (!(pathname.isJar() || pathname.isURL())) { 2145 pathname2155 Pathname result 2146 2156 = mergePathnames(pathname, 2147 2157 coerceToPathname(Symbol.DEFAULT_PATHNAME_DEFAULTS.symbolValue()), 2148 2158 NIL); 2149 final String namestring = pathname.getNamestring(); 2150 if (namestring == null) { 2151 return error(new FileError("Pathname has no namestring: " 2152 + pathname.princToString(), 2153 pathname)); 2154 } 2155 2156 final File file = new File(namestring); 2157 if (file.isDirectory()) { 2158 return Utilities.getDirectoryPathname(file); 2159 } 2159 final File file = result.getFile(); 2160 2160 if (file.exists()) { 2161 try { 2162 return new Pathname(file.getCanonicalPath()); 2163 } catch (IOException e) { 2164 return error(new FileError(e.getMessage(), pathname)); 2165 } 2161 if (file.isDirectory()) { 2162 result = Pathname.getDirectoryPathname(file); 2163 } else { 2164 try { 2165 result = new Pathname(file.getCanonicalPath()); 2166 } catch (IOException e) { 2167 return error(new FileError(e.getMessage(), pathname)); 2168 } 2169 } 2170 return result; 2166 2171 } 2167 2172 } else if (pathname.isURL()) { … … 2344 2349 } 2345 2350 } else { 2346 File file = Utilities.getFile(this);2351 File file = getFile(); 2347 2352 try { 2348 2353 result = new FileInputStream(file); … … 2361 2366 public long getLastModified() { 2362 2367 if (!(isJar() || isURL())) { 2363 File f = Utilities.getFile(this);2368 File f = getFile(); 2364 2369 return f.lastModified(); 2365 2370 } … … 2453 2458 } 2454 2459 2455 File file = Utilities.getFile(defaultedPathname);2460 File file = defaultedPathname.getFile(); 2456 2461 return file.mkdir() ? T : NIL; 2457 2462 } … … 2462 2467 args="filespec new-name", 2463 2468 returns="defaulted-new-name, old-truename, new-truename", 2464 doc="rename-file modifies the file system in such a way that the file indicated by FILESPEC is renamed to DEFAULTED-NEW-NAME.") 2469 doc = "Modifies the file system in such a way that the file indicated by FILESPEC is renamed to DEFAULTED-NEW-NAME.\n" 2470 + "\n" 2471 + "Returns three values if successful. The primary value, DEFAULTED-NEW-NAME, is \n" 2472 + "the resulting name which is composed of NEW-NAME with any missing components filled in by \n" 2473 + "performing a merge-pathnames operation using filespec as the defaults. The secondary \n" 2474 + "value, OLD-TRUENAME, is the truename of the file before it was renamed. The tertiary \n" 2475 + "value, NEW-TRUENAME, is the truename of the file after it was renamed.\n") 2465 2476 private static class pf_rename_file extends Primitive { 2466 2477 pf_rename_file() { … … 2469 2480 @Override 2470 2481 public LispObject execute(LispObject first, LispObject second) { 2471 final Pathname original = (Pathname) truename(first, true);2472 final String originalNamestring = original.getNamestring();2482 Pathname oldPathname = coerceToPathname(first); 2483 Pathname oldTruename = (Pathname) truename(oldPathname, true); 2473 2484 Pathname newName = coerceToPathname(second); 2474 2485 if (newName.isWild()) { 2475 2486 error(new FileError("Bad place for a wild pathname.", newName)); 2476 2487 } 2477 if (o riginal.isJar()) {2478 error(new FileError("Bad place for a jar pathname.", o riginal));2488 if (oldTruename.isJar()) { 2489 error(new FileError("Bad place for a jar pathname.", oldTruename)); 2479 2490 } 2480 2491 if (newName.isJar()) { 2481 2492 error(new FileError("Bad place for a jar pathname.", newName)); 2482 2493 } 2483 if (o riginal.isURL()) {2484 error(new FileError("Bad place for a URL pathname.", o riginal));2494 if (oldTruename.isURL()) { 2495 error(new FileError("Bad place for a URL pathname.", oldTruename)); 2485 2496 } 2486 2497 if (newName.isURL()) { … … 2488 2499 } 2489 2500 2490 newName = mergePathnames(newName, original, NIL); 2491 final String newNamestring; 2492 if (newName instanceof LogicalPathname) { 2493 newNamestring = LogicalPathname.translateLogicalPathname((LogicalPathname) newName).getNamestring(); 2494 } else { 2495 newNamestring = newName.getNamestring(); 2496 } 2497 if (originalNamestring != null && newNamestring != null) { 2498 final File source = new File(originalNamestring); 2499 final File destination = new File(newNamestring); 2500 if (Utilities.isPlatformWindows) { 2501 if (destination.isFile()) { 2502 ZipCache.remove(destination); 2503 destination.delete(); 2504 } 2505 } 2506 if (source.renameTo(destination)) { // Success! 2507 return LispThread.currentThread().setValues(newName, original, 2508 truename(newName, true)); 2509 } 2501 Pathname defaultedNewName = mergePathnames(newName, oldTruename, NIL); 2502 2503 File source = oldTruename.getFile(); 2504 File destination = null; 2505 if (defaultedNewName instanceof LogicalPathname) { 2506 destination = LogicalPathname.translateLogicalPathname((LogicalPathname)defaultedNewName) 2507 .getFile(); 2508 } else { 2509 destination = defaultedNewName.getFile(); 2510 } 2511 // By default, MSDOG doesn't allow one to remove files that are open. 2512 if (Utilities.isPlatformWindows) { 2513 if (destination.isFile()) { 2514 ZipCache.remove(destination); 2515 destination.delete(); 2516 } 2517 } 2518 if (source.renameTo(destination)) { // Success! 2519 Pathname newTruename = (Pathname)truename(defaultedNewName, true); 2520 return LispThread.currentThread().setValues(defaultedNewName, 2521 oldTruename, 2522 newTruename); 2510 2523 } 2511 2524 return error(new FileError("Unable to rename " 2512 + o riginal.princToString()2525 + oldTruename.princToString() 2513 2526 + " to " + newName.princToString() 2514 + ".")); 2527 + ".", 2528 oldTruename)); 2515 2529 } 2516 2530 } … … 2656 2670 return null; // Error 2657 2671 } 2672 2673 2674 File getFile() { 2675 String namestring = getNamestring(); // XXX UNC pathnames currently have no namestring 2676 if (namestring != null) { 2677 return new File(namestring); 2678 } 2679 error(new FileError("Pathname has no namestring: " + princToString(), 2680 this)); 2681 // Not reached. 2682 return null; 2683 } 2684 public static Pathname getDirectoryPathname(File file) { 2685 try { 2686 String namestring = file.getCanonicalPath(); 2687 if (namestring != null && namestring.length() > 0) { 2688 if (namestring.charAt(namestring.length() - 1) != File.separatorChar) { 2689 namestring = namestring.concat(File.separator); 2690 } 2691 } 2692 return new Pathname(namestring); 2693 } catch (IOException e) { 2694 error(new LispError(e.getMessage())); 2695 // Not reached. 2696 return null; 2697 } 2698 } 2699 2658 2700 } 2659 2701 -
TabularUnified trunk/abcl/src/org/armedbear/lisp/Utilities.java ¶
r13440 r14176 91 91 } 92 92 93 public static File getFile(Pathname pathname)94 {95 return getFile(pathname,96 coerceToPathname(Symbol.DEFAULT_PATHNAME_DEFAULTS.symbolValue()));97 }98 99 public static File getFile(Pathname pathname, Pathname defaultPathname)100 101 {102 Pathname merged =103 Pathname.mergePathnames(pathname, defaultPathname, NIL);104 String namestring = merged.getNamestring();105 if (namestring != null)106 return new File(namestring);107 error(new FileError("Pathname has no namestring: " + merged.princToString(),108 merged));109 // Not reached.110 return null;111 }112 113 public static Pathname getDirectoryPathname(File file)114 115 {116 try {117 String namestring = file.getCanonicalPath();118 if (namestring != null && namestring.length() > 0) {119 if (namestring.charAt(namestring.length() - 1) != File.separatorChar)120 namestring = namestring.concat(File.separator);121 }122 return new Pathname(namestring);123 }124 catch (IOException e) {125 error(new LispError(e.getMessage()));126 // Not reached.127 return null;128 }129 }130 131 93 public static ZipInputStream getZipInputStream(ZipFile zipfile, 132 94 String entryName) { -
TabularUnified trunk/abcl/src/org/armedbear/lisp/compile-file.lisp ¶
r14163 r14176 1 1 2 ;;; compile-file.lisp 2 3 ;;; … … 54 55 (%format nil "~A_0" (base-classname output-file-pathname))) 55 56 56 (declaim (ftype (function (t) t) compute-classfile -name))57 (defun compute-classfile -name(n &optional (output-file-pathname57 (declaim (ftype (function (t) t) compute-classfile)) 58 (defun compute-classfile (n &optional (output-file-pathname 58 59 *output-file-pathname*)) 59 "Computes the name of the class file associated with number `n'."60 "Computes the pathname of the class file associated with number `n'." 60 61 (let ((name 61 62 (sanitize-class-name 62 63 (%format nil "~A_~D" (pathname-name output-file-pathname) n)))) 63 ( namestring (merge-pathnames (make-pathname :name name :type *compile-file-class-extension*)64 output-file-pathname))) )64 (merge-pathnames (make-pathname :name name :type *compile-file-class-extension*) 65 output-file-pathname))) 65 66 66 67 (defun sanitize-class-name (name) … … 75 76 76 77 77 (declaim (ftype (function () t) next-classfile -name))78 (defun next-classfile -name()79 (compute-classfile -name(incf *class-number*)))78 (declaim (ftype (function () t) next-classfile)) 79 (defun next-classfile () 80 (compute-classfile (incf *class-number*))) 80 81 81 82 (defmacro report-error (&rest forms) … … 186 187 (expr `(lambda () ,form)) 187 188 (saved-class-number *class-number*) 188 (classfile (next-classfile -name))189 (classfile (next-classfile)) 189 190 (result 190 191 (with-open-file … … 308 309 (jvm::with-saved-compiler-policy 309 310 (let* ((saved-class-number *class-number*) 310 (classfile (next-classfile -name))311 (classfile (next-classfile)) 311 312 (result 312 313 (with-open-file … … 451 452 (let* ((expr (function-lambda-expression (macro-function name))) 452 453 (saved-class-number *class-number*) 453 (classfile (next-classfile -name)))454 (classfile (next-classfile))) 454 455 (with-open-file 455 456 (f classfile … … 491 492 ,@decls (block ,block-name ,@body))) 492 493 (saved-class-number *class-number*) 493 (classfile (next-classfile -name))494 (classfile (next-classfile)) 494 495 (internal-compiler-errors nil) 495 496 (result (with-open-file … … 637 638 638 639 (defun populate-zip-fasl (output-file) 639 (let* ((type ;; Don't use ".zip", it'll result in an extension 640 ;; witha dot, which is rejected by NAMESTRING640 (let* ((type ;; Don't use ".zip", it'll result in an extension with 641 ;; a dot, which is rejected by NAMESTRING 641 642 (%format nil "~A~A" (pathname-type output-file) "-zip")) 642 (zipfile (namestring 643 (merge-pathnames (make-pathname :type type) 644 output-file))) 643 (output-file (if (logical-pathname-p output-file) 644 (translate-logical-pathname output-file) 645 output-file)) 646 (zipfile 647 (if (find :windows *features*) 648 (make-pathname :defaults output-file :type type) 649 (make-pathname :defaults output-file :type type 650 :device :unspecific))) 645 651 (pathnames nil) 646 (fasl-loader (namestring (merge-pathnames 647 (make-pathname :name (fasl-loader-classname) 648 :type *compile-file-class-extension*) 649 output-file)))) 652 (fasl-loader (make-pathname :defaults output-file 653 :name (fasl-loader-classname) 654 :type *compile-file-class-extension*))) 650 655 (when (probe-file fasl-loader) 651 656 (push fasl-loader pathnames)) 652 657 (dotimes (i *class-number*) 653 (let ((truename (probe-file (compute-classfile -name(1+ i)))))658 (let ((truename (probe-file (compute-classfile (1+ i))))) 654 659 (when truename 655 660 (push truename pathnames) … … 669 674 (push resource pathnames)))))) 670 675 (setf pathnames (nreverse (remove nil pathnames))) 671 (let ((load-file (m erge-pathnames (make-pathname :type "_")672 output-file)))676 (let ((load-file (make-pathname :defaults output-file 677 :type "_"))) 673 678 (rename-file output-file load-file) 674 679 (push load-file pathnames)) … … 711 716 (defvar *fasl-stream* nil) 712 717 718 (defvar *debug-compile-from-stream* nil) 713 719 (defun compile-from-stream (in output-file temp-file temp-file2 714 720 extract-toplevel-funcs-and-macros … … 723 729 (start (get-internal-real-time)) 724 730 *fasl-uninterned-symbols*) 731 (setf *debug-compile-from-stream* 732 (list :in in 733 :compile-file-pathname *compile-file-pathname*)) 725 734 (when *compile-verbose* 726 735 (format t "; Compiling ~A ...~%" namestring)) … … 849 858 do (write-line line out))))) 850 859 (delete-file temp-file) 851 (remove-zip-cache-entry output-file) ;; Necessary under windows 860 (when (find :windows *features*) 861 (remove-zip-cache-entry output-file)) 852 862 (rename-file temp-file2 output-file) 853 863 … … 871 881 (when suffix 872 882 (setq type (concatenate 'string type suffix))) 873 (merge-pathnames (make-pathname :type type) 874 pathname))) 883 (make-pathname :type type :defaults pathname))) 875 884 (unless (or (and (probe-file input-file) 876 885 (not (file-directory-p input-file))) -
TabularUnified trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp ¶
r14143 r14176 7556 7556 (defmacro with-file-compilation (&body body) 7557 7557 `(let ((*file-compilation* t) 7558 (*pathnames-generator* #'sys::next-classfile -name))7558 (*pathnames-generator* #'sys::next-classfile)) 7559 7559 ,@body)) 7560 7560 -
TabularUnified trunk/abcl/src/org/armedbear/lisp/directory.lisp ¶
r13252 r14176 118 118 (cond ((file-directory-p entry) 119 119 (when (pathname-match-p (file-namestring (pathname-as-file entry)) (file-namestring pathname)) 120 (push entrymatching-entries)))120 (push (truename entry) matching-entries))) 121 121 ((pathname-match-p (or (file-namestring entry) "") (file-namestring pathname)) 122 (push entrymatching-entries))))122 (push (truename entry) matching-entries)))) 123 123 matching-entries)))) 124 124 ;; Not wild. -
TabularUnified trunk/abcl/src/org/armedbear/lisp/dump-form.lisp ¶
r13653 r14176 176 176 index)) 177 177 178 (declaim (ftype (function (pathname stream) t) dump-pathname)) 179 (defun dump-pathname (pathname stream) 180 (write-string "#P(" stream) 181 (write-string ":HOST " stream) 182 (dump-form (pathname-host pathname) stream) 183 (write-string " :DEVICE " stream) 184 (dump-form (pathname-device pathname) stream) 185 (write-string " :DIRECTORY " stream) 186 (dump-form (pathname-directory pathname) stream) 187 (write-string " :NAME " stream) 188 (dump-form (pathname-name pathname) stream) 189 (write-string " :TYPE " stream) 190 (dump-form (pathname-type pathname) stream) 191 (write-string " :VERSION " stream) 192 (dump-form (pathname-version pathname) stream) 193 (write-string ")" stream)) 194 178 195 (declaim (ftype (function (t stream) t) dump-object)) 179 196 (defun dump-object (object stream) … … 183 200 ((stringp object) 184 201 (%stream-output-object object stream)) 202 ((pathnamep object) 203 (dump-pathname object stream)) 185 204 ((bit-vector-p object) 186 205 (%stream-output-object object stream)) -
TabularUnified trunk/abcl/src/org/armedbear/lisp/file_write_date.java ¶
r12422 r14176 52 52 if (pathname.isWild()) 53 53 error(new FileError("Bad place for a wild pathname.", pathname)); 54 long lastModified = pathname.getLastModified(); 54 Pathname defaultedPathname = (Pathname) Pathname.MERGE_PATHNAMES.execute(pathname); 55 long lastModified = defaultedPathname.getLastModified(); 55 56 if (lastModified == 0) 56 57 return NIL; -
TabularUnified trunk/abcl/src/org/armedbear/lisp/probe_file.java ¶
r12290 r14176 75 75 if (pathname.isWild()) 76 76 error(new FileError("Bad place for a wild pathname.", pathname)); 77 File file = Utilities.getFile(pathname); 78 return file.isDirectory() ? Utilities.getDirectoryPathname(file) : NIL; 77 Pathname defaultedPathname = (Pathname)Pathname.MERGE_PATHNAMES.execute(pathname); 78 File file = defaultedPathname.getFile(); 79 return file.isDirectory() ? Pathname.getDirectoryPathname(file) : NIL; 79 80 } 80 81 }; … … 86 87 { 87 88 @Override 88 public LispObject execute(LispObject arg) 89 public LispObject execute(LispObject arg) // XXX Should this merge with defaults? 89 90 { 90 91 Pathname pathname = coerceToPathname(arg); 91 92 if (pathname.isWild()) 92 93 error(new FileError("Bad place for a wild pathname.", pathname)); 93 File file = Utilities.getFile(pathname);94 File file = pathname.getFile(); 94 95 return file.isDirectory() ? T : NIL; 95 96 } -
TabularUnified trunk/abcl/src/org/armedbear/lisp/zip.java ¶
r13440 r14176 216 216 final Pathname source = Lisp.coerceToPathname(key); 217 217 final Pathname destination = Lisp.coerceToPathname(value); 218 final File file = Utilities.getFile(source);218 final File file = source.getFile(); 219 219 try { 220 220 String jarEntry = destination.getNamestring();
Note: See TracChangeset
for help on using the changeset viewer.