Mercurial > hg > digilib-old
comparison servlet/src/digilib/io/FileOps.java @ 56:2ea78a56ecf8
Use system specific pathSeparator for documents paths (; on Win).
Fix Error accessing files when only one document path was specified.
(ROC)
author | robcast |
---|---|
date | Tue, 27 Aug 2002 12:29:07 +0200 |
parents | 0ff3ede32060 |
children | 5ea1999befd4 |
comparison
equal
deleted
inserted
replaced
55:1a0b955ef254 | 56:2ea78a56ecf8 |
---|---|
116 */ | 116 */ |
117 public File getFileVariant(String[] dirs, String fn, int n, boolean fwd) throws FileOpException { | 117 public File getFileVariant(String[] dirs, String fn, int n, boolean fwd) throws FileOpException { |
118 util.dprintln(4, "getVariantFile ("+dirs+", "+fn+", "+n+")"); | 118 util.dprintln(4, "getVariantFile ("+dirs+", "+fn+", "+n+")"); |
119 | 119 |
120 File f = null; | 120 File f = null; |
121 int start = 0; | 121 int nvar = dirs.length; |
122 int inc = 1; | |
123 int end = dirs.length; | |
124 if (fwd == false) { | |
125 start = dirs.length - 1; | |
126 inc = -1; | |
127 end = 0; | |
128 } | |
129 | 122 |
130 for (int i = start; i != end; i += inc) { | 123 for (int i = 0; i < nvar; i++) { |
131 try { | 124 try { |
132 f = getFile(dirs[i]+fn, n); | 125 f = getFile(dirs[(fwd) ? i : (nvar-i-1)]+fn, n); |
133 } catch (FileOpException e) { | 126 } catch (FileOpException e) { |
134 f = null; | 127 f = null; |
135 } | 128 } |
136 if (f != null) { | 129 if (f != null) { |
137 return f; | 130 return f; |
147 */ | 140 */ |
148 public int getNumFilesVariant(String[] dirs, String fn, boolean fwd) throws FileOpException { | 141 public int getNumFilesVariant(String[] dirs, String fn, boolean fwd) throws FileOpException { |
149 util.dprintln(4, "getNumFilesVariant ("+dirs+", "+fn+")"); | 142 util.dprintln(4, "getNumFilesVariant ("+dirs+", "+fn+")"); |
150 | 143 |
151 int nf = 0; | 144 int nf = 0; |
152 int start = 0; | 145 int nvar = dirs.length; |
153 int inc = 1; | |
154 int end = dirs.length; | |
155 if (fwd == false) { | |
156 start = dirs.length - 1; | |
157 inc = -1; | |
158 end = 0; | |
159 } | |
160 | 146 |
161 for (int i = start; i != end; i += inc) { | 147 for (int i = 0; i < nvar; i++) { |
162 try { | 148 try { |
163 nf = getNumFiles(dirs[i]+fn); | 149 nf = getNumFiles(dirs[(fwd) ? i : (nvar-i-1)]+fn); |
164 } catch (FileOpException e) { | 150 } catch (FileOpException e) { |
165 nf = 0; | 151 nf = 0; |
166 } | 152 } |
167 if (nf > 0) { | 153 if (nf > 0) { |
168 return nf; | 154 return nf; |