Changeset 2913
- Timestamp:
- Nov 15, 2006, 8:37:31 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/File.java
r2904 r2913 454 454 { 455 455 // an old file exists 456 internalFile = new java.io.File(Application.getUserFilesDirectory(),getInternalName());456 internalFile = getAbsolutePath(getInternalName()); 457 457 } 458 458 if (newInternalFile != null) … … 871 871 return new ByteArrayInputStream(new byte[0]); 872 872 } 873 java.io.File file = newInternalFile != null ? newInternalFile : new java.io.File(Application.getUserFilesDirectory(),getInternalName());874 if (!file.exists())873 java.io.File file = newInternalFile != null ? newInternalFile : getAbsolutePath(getInternalName()); 874 if (!file.exists()) 875 875 { 876 876 return new ByteArrayInputStream(new byte[0]); … … 891 891 } 892 892 893 private static final SimpleDateFormat SUBDIR_FORMAT = new SimpleDateFormat("yyyy-ww"); 893 private static final String separator = java.io.File.separator; 894 private static final SimpleDateFormat SUBDIR_FORMAT = 895 new SimpleDateFormat("yyyy-ww"+separator+"F-ss"); 894 896 895 897 /** … … 935 937 /** 936 938 Get the relative path of the specified file from the base upload 937 directory .939 directory and convert directory separator to forward slash. 938 940 @since 2.2 941 @see #getAbsolutePath(String) 939 942 */ 940 943 private String getRelativePath(java.io.File file) … … 943 946 String rootPath = Application.getUserFilesDirectory().getAbsolutePath(); 944 947 String relPath = absPath.replace(rootPath, ""); 945 if (relPath.startsWith(java.io.File.separator)) 946 { 947 relPath = relPath.substring(java.io.File.separator.length()); 948 } 948 if (relPath.startsWith(separator)) 949 { 950 relPath = relPath.substring(separator.length()); 951 } 952 relPath = relPath.replaceAll(separator, "/"); 949 953 return relPath; 954 } 955 956 /** 957 Convert a relative path back to an absolute file path. 958 @since 2.2 959 @see #getRelativePath(java.io.File) 960 */ 961 private java.io.File getAbsolutePath(String relativePath) 962 { 963 // Convert forward slash to file system separator 964 relativePath = relativePath.replaceAll("/", separator); 965 return new java.io.File(Application.getUserFilesDirectory(), relativePath); 950 966 } 951 967
Note: See TracChangeset
for help on using the changeset viewer.