|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.mj.impl.fileutils; |
|
19 |
|
20 import java.io.DataInputStream; |
|
21 import java.io.DataOutputStream; |
|
22 import java.io.IOException; |
|
23 import java.io.InputStream; |
|
24 import java.io.OutputStream; |
|
25 import java.lang.IllegalArgumentException; |
|
26 import java.lang.SecurityException; |
|
27 import java.util.Enumeration; |
|
28 import java.util.Random; |
|
29 import java.util.Vector; |
|
30 /* |
|
31 import javax.microedition.io.Connector; |
|
32 |
|
33 import com.nokia.mj.impl.rt.support.Finalizer; |
|
34 import com.nokia.mj.impl.rt.support.Jvm; |
|
35 import com.nokia.mj.impl.utils.Logger; |
|
36 import com.nokia.mj.impl.utils.Tokenizer;*/ |
|
37 |
|
38 /** |
|
39 * FileUtility provides File handling APIs for internal use in OMJ. |
|
40 * |
|
41 * <p> |
|
42 * <strong>Creating FileUtility</strong> |
|
43 * <p> |
|
44 * The pathname used to create the FileUtility object must always be abolute. An |
|
45 * absolute pathname is complete in that no other information is required in |
|
46 * order to locate the file that it denotes. A relative pathname, in contrast, |
|
47 * must be interpreted in terms of information taken from some other pathname. |
|
48 * Relative paths cannot be passed to the constructor of FileUtility. |
|
49 * FileUtility.getCanonicalPath() can be used to resolve relative paths to |
|
50 * absolute path. |
|
51 * <p> |
|
52 * File URL can also be used to create FileUtility object. The format of the |
|
53 * input string used to access a FileUtility must follow the format of a |
|
54 * fully-qualified, absolute path file name as described by the file URL format |
|
55 * in IETF RFCs 1738 & 2396. |
|
56 * |
|
57 * <p> |
|
58 * <strong>FileUtility Behavior</strong> |
|
59 * <p> |
|
60 * FileUtility can be created immeterial of whether the intended iTarget exists |
|
61 * or not. This behavior allows the creation of new files and directories on a |
|
62 * file system. For example, the following code snippet can be used to create a |
|
63 * file on the file system. |
|
64 * |
|
65 * <pre> |
|
66 * try |
|
67 * { |
|
68 * FileUtility fileTarget = new FileUtility("/home/user1/newFile.txt"); |
|
69 * // If no exception is thrown, URI is valid, but file may or may not exist |
|
70 * |
|
71 * if (!fileTarget.exists()) |
|
72 * { |
|
73 * fileTarget.createNewFile(); |
|
74 * } |
|
75 * |
|
76 * fileTarget = null; |
|
77 * } |
|
78 * catch (IOException ex) |
|
79 * { |
|
80 * } |
|
81 * </pre> |
|
82 * |
|
83 * Developers should always check for the file's or directory's existence after |
|
84 * a construction to determine if the file or directory actually exists. |
|
85 * Similarly, files or directories can be deleted using the delete() method. |
|
86 * |
|
87 * <p> |
|
88 * <strong>Streams in FileUtility</strong> |
|
89 * <p> |
|
90 * Input and output streams may be opened and closed multiple times on a |
|
91 * FileUtility instance.<br/> |
|
92 * |
|
93 * All FileUtility instances have one underlying InputStream and one |
|
94 * OutputStream. Opening a DataInputStream counts as opening an InputStream, and |
|
95 * opening a DataOutputStream counts as opening an OutputStream. A FileUtility |
|
96 * instance can have only one InputStream and one OutputStream open at any one |
|
97 * time. Trying to open more than one InputStream or more than one OutputStream |
|
98 * from a StreamConnection causes an IOException. Further detials can be found |
|
99 * in Common Streams. |
|
100 * <p> |
|
101 * Instances of the FileUtility class are immutable; that is, once created, the |
|
102 * pathname represented by a FileUtility object will never change. |
|
103 * |
|
104 */ |
|
105 public final class FileUtility |
|
106 { |
|
107 /** |
|
108 * File name passed here should be absolute path. |
|
109 * |
|
110 * @param aFilePath |
|
111 * file/directory that FileUtility must work on. |
|
112 */ |
|
113 public FileUtility(String aFilePath) |
|
114 { |
|
115 } |
|
116 |
|
117 /** |
|
118 * Constructs a FileUtility with given parameters. This is to be used when |
|
119 * trying to access DRM protected content. |
|
120 * |
|
121 * @param aFilePath |
|
122 * absolute path of the file/directory. |
|
123 * @param aDrmIntent |
|
124 * intent with which the user wants to open the file. The DRM |
|
125 * intent specified must be one of the values present in |
|
126 * FileDRMContentHandler |
|
127 * @param aExecuteIntent |
|
128 * specifies whether to execute the intent when an InputStream is |
|
129 * opened on the file. |
|
130 * @see FileDRMContentHandler |
|
131 */ |
|
132 public FileUtility(String aFilePath, int aDrmIntent, boolean aExecuteIntent) |
|
133 { |
|
134 } |
|
135 |
|
136 |
|
137 /** |
|
138 * Creates a new empty file in the specified directory, using the given |
|
139 * prefix and suffix strings to generate its name. If this method returns |
|
140 * successfully then it is guaranteed that: |
|
141 * <ol> |
|
142 * <li>The file denoted by the returned abstract pathname did not exist |
|
143 * before this method was invoked, and</li> |
|
144 * <li>Neither this method nor any of its variants will return the same |
|
145 * abstract pathname again in the current invocation of the virtual machine. |
|
146 * </li> |
|
147 * </ol> |
|
148 * <p> |
|
149 * The prefix argument must be at least three characters long. It is |
|
150 * recommended that the prefix be a short, meaningful string such as "hjb" |
|
151 * or "mail".<br/> |
|
152 * The suffix argument may be null, in which case the suffix ".tmp" will be |
|
153 * used. <br/> |
|
154 * The directory argument should not be null and must provide a directory to |
|
155 * which the file has to be created. |
|
156 * <p> |
|
157 * New file will be generated by concatenating the prefix, five or more |
|
158 * internally-generated characters, and the suffix. |
|
159 * |
|
160 * @param aPrefix |
|
161 * The prefix string to be used in generating the file's name |
|
162 * must be at least three characters long |
|
163 * @param aSuffix |
|
164 * The suffix string to be used in generating the file's name may |
|
165 * be null, in which case the suffix ".tmp" will be used |
|
166 * @param aDirectory |
|
167 * The directory in which the file is to be created |
|
168 * @return A new FileUtility instance denoting the newly created file. |
|
169 * @throws IOException |
|
170 * if the file could not be created or the directory does not |
|
171 * exist |
|
172 * @throws IllegalArgumentException |
|
173 * if the prefix is fewer than three characters or directory |
|
174 * parameter is null |
|
175 * @throws SecurityException |
|
176 * if access was not allowed to create a file in the directory |
|
177 * specified |
|
178 */ |
|
179 public static FileUtility createTempFile(String aPrefix, String aSuffix, |
|
180 FileUtility aDirectory) throws IOException |
|
181 { |
|
182 return null; |
|
183 } |
|
184 |
|
185 /** |
|
186 * Resolves incomplete path by prefixing the path with one of the roots of |
|
187 * the file system. |
|
188 * <p> |
|
189 * |
|
190 * <pre> |
|
191 * Example of S60: |
|
192 * String resolved = FileUtility.resolve("\\data\\images\\existingFile"); |
|
193 * // resolved will be C:\data\images\existingFile |
|
194 * </pre> |
|
195 * |
|
196 * @param aPath |
|
197 * incomplete path that does not contain drive information. |
|
198 * @return resolved path or null if not found |
|
199 */ |
|
200 public static String resolveDrive(String aPath) |
|
201 { |
|
202 return null; |
|
203 } |
|
204 |
|
205 /** |
|
206 * A canonical pathname is both absolute and unique. The precise definition |
|
207 * of canonical form is system-dependent. This method first converts this |
|
208 * pathname to absolute form if necessary, and then maps it to its unique |
|
209 * form in a system-dependent way. This typically involves removing |
|
210 * redundant names such as "." and ".." from the pathname, resolving |
|
211 * symbolic links (on UNIX platforms), and converting drive letters to a |
|
212 * standard case (on Microsoft Windows platforms). |
|
213 * <p> |
|
214 * Every pathname that denotes an existing file or directory has a unique |
|
215 * canonical form. Every pathname that denotes a nonexistent file or |
|
216 * directory also has a unique canonical form. |
|
217 * |
|
218 * @param aPath |
|
219 * @return The canonical pathname string denoting the same file or |
|
220 * directory. |
|
221 * @throws IOException |
|
222 * If an I/O error occurs, which is possible because the |
|
223 * construction of the canonical pathname may require filesystem |
|
224 * queries |
|
225 * |
|
226 */ |
|
227 public static String getCanonicalPath(String aPath) throws IOException |
|
228 { |
|
229 return null; |
|
230 } |
|
231 |
|
232 /** |
|
233 * Get file Content ID. Only DRM protected files have content Id. |
|
234 * |
|
235 * @param full |
|
236 * path to file. |
|
237 * @return Content ID. Null if cannot be read or does not exists. |
|
238 */ |
|
239 public static String getContentId(String aPath) |
|
240 { |
|
241 return null; |
|
242 } |
|
243 |
|
244 |
|
245 /** |
|
246 * Open and return an input stream for a connection. The connection's |
|
247 * iTarget must already exist and be accessible for the input stream to be |
|
248 * created. |
|
249 * |
|
250 * @return An open input stream |
|
251 * @throws IOException |
|
252 * if an I/O error occurs, if the method is invoked on a |
|
253 * directory, if the connection's iTarget does not yet exist, or |
|
254 * the connection's iTarget is not accessible. |
|
255 */ |
|
256 public InputStream openInputStream() throws IOException |
|
257 { |
|
258 return null; |
|
259 } |
|
260 |
|
261 /** |
|
262 * Open and return a data input stream for a connection. The connection's |
|
263 * iTarget must already exist and be accessible for the input stream to be |
|
264 * created. |
|
265 * |
|
266 * @return An open input stream |
|
267 * @throws IOException |
|
268 * If an I/O error occurs, if the method is invoked on a |
|
269 * directory, if the connection's iTarget does not yet exist, or |
|
270 * the connection's iTarget is not accessible. |
|
271 */ |
|
272 public DataInputStream openDataInputStream() throws IOException |
|
273 { |
|
274 return null; |
|
275 } |
|
276 |
|
277 /** |
|
278 * Open and return an output stream for a connection. The output stream is |
|
279 * positioned at the start of the file. Writing data to the output stream |
|
280 * overwrites the contents of the files (i.e. does not insert data). Writing |
|
281 * data to output streams beyond the current end of file automatically |
|
282 * extends the file size. The connection's iTarget must already exist and be |
|
283 * accessible for the output stream to be created. openOutputStream(long) |
|
284 * should be used to position an output stream to a different position in |
|
285 * the file. |
|
286 * <p> |
|
287 * Changes made to a file through an output stream may not be immediately |
|
288 * made to the actual file residing on the file system because platform and |
|
289 * implementation specific use of caching and buffering of the data. Stream |
|
290 * contents and file length extensions are not necessarily visible outside |
|
291 * of the application immediately unless flush() is called on the stream. |
|
292 * The returned output stream is automatically and synchronously flushed |
|
293 * when it is closed. |
|
294 * |
|
295 * @return An open output stream |
|
296 * @throws IOException |
|
297 * If an I/O error occurs, if the method is invoked on a |
|
298 * directory, the file does not yet exist, or the connection's |
|
299 * iTarget is not accessible. |
|
300 */ |
|
301 public OutputStream openOutputStream() throws IOException |
|
302 { |
|
303 return null; |
|
304 } |
|
305 |
|
306 /** |
|
307 * Open and return a data output stream for a connection. The output stream |
|
308 * is positioned at the start of the file. Writing data to the output stream |
|
309 * overwrites the contents of the files (i.e. does not insert data). Writing |
|
310 * data to output streams beyond the current end of file automatically |
|
311 * extends the file size. The connection's iTarget must already exist and be |
|
312 * accessible for the output stream to be created. openOutputStream(long) |
|
313 * should be used to position an output stream to a different position in |
|
314 * the file. |
|
315 * <p> |
|
316 * Changes made to a file through an output stream may not be immediately |
|
317 * made to the actual file residing on the file system because platform and |
|
318 * implementation specific use of caching and buffering of the data. Stream |
|
319 * contents and file length extensions are not necessarily visible outside |
|
320 * of the application immediately unless flush() is called on the stream. |
|
321 * The returned output stream is automatically and synchronously flushed |
|
322 * when it is closed. |
|
323 * |
|
324 * @return An open output stream |
|
325 * @throws IOException |
|
326 * If an I/O error occurs, if the method is invoked on a |
|
327 * directory, the file does not yet exist, or the connection's |
|
328 * iTarget is not accessible. |
|
329 */ |
|
330 public DataOutputStream openDataOutputStream() throws IOException |
|
331 { |
|
332 return null; |
|
333 } |
|
334 |
|
335 /** |
|
336 * This method opens an output stream and positions it at the indicated byte |
|
337 * offset in the file. Data written to the returned output stream at that |
|
338 * position overwrites any existing data until EOF is reached, and then |
|
339 * additional data is appended. The connection's iTarget must already exist |
|
340 * and be accessible for the output stream to be created. |
|
341 * <p> |
|
342 * Changes made to a file through an output stream may not be immediately |
|
343 * made to the actual file residing on the file system because platform and |
|
344 * implementation specific use of caching and buffering of the data. Stream |
|
345 * contents and file length extensions are not necessarily visible outside |
|
346 * of the application immediately unless flush() is called on the stream. |
|
347 * The returned output stream is automatically and synchronously flushed |
|
348 * when it is closed. |
|
349 * |
|
350 * @param aByteOffset |
|
351 * number of bytes to skip over from the beginning of the file |
|
352 * when positioning the start of the OutputStream. If the |
|
353 * provided offset is larger than or equal to the current file |
|
354 * size, the OutputStream is positioned at the current end of the |
|
355 * file for appending. |
|
356 * @return an open OutputStream positioned at the byte offset in the file, |
|
357 * or the end of the file if the offset is greater than the size of |
|
358 * the file. |
|
359 * @throws IOException |
|
360 * If an I/O error occurs, if the method is invoked on a |
|
361 * directory, the file does not yet exist, or the connection's |
|
362 * iTarget is not accessible. |
|
363 */ |
|
364 public OutputStream openOutputStream(long aByteOffset) throws IOException |
|
365 { |
|
366 return null; |
|
367 } |
|
368 |
|
369 /** |
|
370 * Checks to see if current FileUtility is pointing to a File. |
|
371 * |
|
372 * @return true if the current iTarget is a file. false in case the iTarget |
|
373 * is not a file or is not accessible. |
|
374 */ |
|
375 public boolean isFile() |
|
376 { |
|
377 return false; |
|
378 } |
|
379 |
|
380 /** |
|
381 * Checks to see if the current FileUtility is pointing to a Directory. |
|
382 * |
|
383 * @return true if the current iTarget is a directory. false in case the |
|
384 * iTarget is not a directory or is not accessbile. |
|
385 */ |
|
386 public boolean isDirectory() |
|
387 { |
|
388 return false; |
|
389 } |
|
390 |
|
391 /** |
|
392 * Checks to see if the current FileUtility iTarget exists. |
|
393 * |
|
394 * @return true if the current iTarget exists. false in case the iTarget did |
|
395 * not exist or there was a fault while reading or accessing the |
|
396 * file. |
|
397 */ |
|
398 public boolean exists() |
|
399 { |
|
400 return false; |
|
401 } |
|
402 |
|
403 /** |
|
404 * Checks to see if the current FileUtility iTarget can be read from the |
|
405 * current application. |
|
406 * |
|
407 * @return true if read access is allowed to the file. false if read access |
|
408 * is not allowed or if there was error reading the file. |
|
409 */ |
|
410 public boolean canRead() |
|
411 { |
|
412 return false; |
|
413 } |
|
414 |
|
415 /** |
|
416 * Checks to see if the current FileUtility iTarget can be written to from |
|
417 * the current application. |
|
418 * |
|
419 * @return true if write access is allowed to the file. false if write |
|
420 * access is not allowed or if there was error reading the file. |
|
421 */ |
|
422 public boolean canWrite() |
|
423 { |
|
424 return false; |
|
425 } |
|
426 |
|
427 /** |
|
428 * Tests whether the file named by pathname is a hidden file. |
|
429 * <p> |
|
430 * The exact definition of hidden is system-dependent. On UNIX systems, a |
|
431 * file is considered to be hidden if its name begins with a period |
|
432 * character ('.'). On Microsoft Windows systems, a file is considered to be |
|
433 * hidden if it has been marked as such in the filesystem. |
|
434 * <p> |
|
435 * NOTE: There is no method provided to hide a file/directory. |
|
436 * |
|
437 * @return true if the file exists, is accessible, and is hidden, otherwise |
|
438 * false. |
|
439 * |
|
440 */ |
|
441 public boolean isHidden(String aPath) |
|
442 { |
|
443 return false; |
|
444 } |
|
445 |
|
446 /** |
|
447 * Tests whether the file named by pathname is a hidden file. |
|
448 * <p> |
|
449 * The exact definition of hidden is system-dependent. On UNIX systems, a |
|
450 * file is considered to be hidden if its name begins with a period |
|
451 * character ('.'). On Microsoft Windows systems, a file is considered to be |
|
452 * hidden if it has been marked as such in the filesystem. |
|
453 * <p> |
|
454 * NOTE: There is no method provided to hide a file/directory. |
|
455 * |
|
456 * @return true if the file exists, is accessible, and is hidden, otherwise |
|
457 * false. |
|
458 */ |
|
459 public boolean isHidden() |
|
460 { |
|
461 return false; |
|
462 } |
|
463 |
|
464 /** |
|
465 * Sets the file or directory readable attribute to the indicated value. The |
|
466 * readable attribute for the file on the actual file system is set |
|
467 * immediately upon invocation of this method. |
|
468 * |
|
469 * @param aReadable |
|
470 * The new state of the readable flag of the selected file. |
|
471 * @throws IOException |
|
472 * if the connection's iTarget does not exist or is not |
|
473 * accessible. |
|
474 */ |
|
475 public void setReadable(boolean aReadable) throws IOException |
|
476 { |
|
477 } |
|
478 |
|
479 /** |
|
480 * Sets the selected file or directory writable attribute to the indicated |
|
481 * value. The writable attribute for the file on the actual file system is |
|
482 * set immediately upon invocation of the method. |
|
483 * |
|
484 * @param aWritable |
|
485 * The new state of the writable flag of the selected file. |
|
486 * @throws IOException |
|
487 * if the connection's iTarget does not exist or is not |
|
488 * accessible. |
|
489 */ |
|
490 public void setWritable(boolean aWritable) throws IOException |
|
491 { |
|
492 } |
|
493 |
|
494 /** |
|
495 * Sets the hidden attribute of the selected file to the value provided. The |
|
496 * attribute is applied to the file on the actual file system immediately |
|
497 * upon invocation of this method if the file system and platform support |
|
498 * it. |
|
499 * <p> |
|
500 * If the file system doesn't support a hidden attribute, this method is |
|
501 * ignored and isHidden() always returns false. Since the exact definition |
|
502 * of hidden is system-dependent, this method only works on file systems |
|
503 * that support a settable file attribute. |
|
504 * <p> |
|
505 * For example, on Win32 and FAT file systems, a file may be considered |
|
506 * hidden if it has been marked as such in the file's attributes; therefore |
|
507 * this method is applicable.<br/> |
|
508 * However on UNIX systems a file may be considered to be hidden if its name |
|
509 * begins with a period character ('.'). In the UNIX case, this method may |
|
510 * be ignored and the method to make a file hidden may be the rename() |
|
511 * method. |
|
512 * |
|
513 * @param aHidden |
|
514 * The new state of the hidden flag of the selected file. |
|
515 * @throws IOException |
|
516 * if the connection's iTarget does not exist or is not |
|
517 * accessible. |
|
518 */ |
|
519 public void setHidden(boolean aHidden) throws IOException |
|
520 { |
|
521 } |
|
522 |
|
523 /** |
|
524 * Retrieves the size of the file. |
|
525 * |
|
526 * @return size of file in bytes or -1 if the file did not exist |
|
527 * @throws IOException |
|
528 * in case there was any error retrieving the file size. |
|
529 */ |
|
530 public long fileSize() throws IOException |
|
531 { |
|
532 return 0; |
|
533 } |
|
534 |
|
535 /** |
|
536 * Determines the size in bytes on a file system of all of the files that |
|
537 * are contained in a directory. |
|
538 * |
|
539 * @param aIncludeSubDirs |
|
540 * specifies if dir size has to be taken recursively |
|
541 * @return The size in bytes occupied by the files included in the |
|
542 * directory, \ or -1 if the directory does not exist or is not |
|
543 * accessible. |
|
544 * |
|
545 * @throws IOException |
|
546 * if the method is invoked on a file. |
|
547 * |
|
548 * @throws SecurityException |
|
549 * if the security of the application does not have read access |
|
550 * to the file. |
|
551 */ |
|
552 public long directorySize(boolean aIncludeSubDirs) throws IOException |
|
553 { |
|
554 return 0; |
|
555 } |
|
556 |
|
557 /** |
|
558 * Determines the total size of the file system the iTarget resides on. |
|
559 * |
|
560 * @return The total size of the file system in bytes, or -1 if the file |
|
561 * system is not accessible. |
|
562 */ |
|
563 public long totalSize() |
|
564 { |
|
565 return 0; |
|
566 } |
|
567 |
|
568 /** |
|
569 * Determines the free memory that is available on the file system the file |
|
570 * or directory resides on. This may only be an estimate and may vary based |
|
571 * on platform-specific file system blocking and metadata information. |
|
572 * |
|
573 * @return The available size in bytes on a file system, or -1 if the file |
|
574 * system is not accessible. |
|
575 */ |
|
576 public long availableSize() |
|
577 { |
|
578 return 0; |
|
579 } |
|
580 |
|
581 /** |
|
582 * Determines the used memory of a file system the connection's iTarget |
|
583 * resides on. This may only be an estimate and may vary based on |
|
584 * platform-specific file system blocking and metadata information. |
|
585 * |
|
586 * @return The used size of bytes on a file system, or -1 if the file system |
|
587 * is not accessible. |
|
588 */ |
|
589 public long usedSize() |
|
590 { |
|
591 return 0; |
|
592 } |
|
593 |
|
594 /** |
|
595 * Returns the time that the FileUtility currently points to was last |
|
596 * modified. |
|
597 * |
|
598 * @return A long value representing the time the file was last modified, |
|
599 * measured in milliseconds, 0L if an I/O error occurs. If |
|
600 * modification date is not supported by the underlying platform |
|
601 * and/or file system, then 0L is also returned. If the connection's |
|
602 * iTarget does not exist or is not accessible, 0L is returned. |
|
603 */ |
|
604 public long lastModified() |
|
605 { |
|
606 return 0; |
|
607 } |
|
608 |
|
609 /** |
|
610 * Fetches the name of the iTarget currently pointed to by FileUtility. If |
|
611 * the iTarget is a file, the result is of the form <file.extention> else if |
|
612 * it is a directory it has a trailing "/" of the form <directory/> |
|
613 * |
|
614 * @return name of the iTarget currently pointed to. |
|
615 */ |
|
616 public String getName() |
|
617 { |
|
618 return null; |
|
619 } |
|
620 |
|
621 /** |
|
622 * Fetches the path to the iTarget currently pointed to by FileUtility. |
|
623 * Return value is of the form /<root>/<directory>/ |
|
624 * |
|
625 * @return path to the iTarget currently pointed to. |
|
626 */ |
|
627 public String getPath() |
|
628 { |
|
629 return null; |
|
630 } |
|
631 |
|
632 /** |
|
633 * Returns FileUtility object that points to the parent of the current |
|
634 * iTarget. |
|
635 * |
|
636 * @return The parent directory named by this FileUtility, or null if this |
|
637 * pathname does not name a parent |
|
638 */ |
|
639 public FileUtility getParentFile() |
|
640 { |
|
641 return null; |
|
642 } |
|
643 |
|
644 /** |
|
645 * Returns the absolute path traced from the root of the file system. |
|
646 * |
|
647 * @return the absolute path of the file |
|
648 */ |
|
649 public String getAbsolutePath() |
|
650 { |
|
651 return null; |
|
652 } |
|
653 |
|
654 /** |
|
655 * Returns the full file URL including the scheme, host, and path from where |
|
656 * the file or directory specified in the Connector.open() method is opened. |
|
657 * The string returned is in an escaped ASCII format as defined by RFC 2396. |
|
658 * The resulting String looks as follows: |
|
659 * |
|
660 * <pre> |
|
661 * file://<host>/<root>/<directory>/<filename> |
|
662 * </pre> |
|
663 * |
|
664 * @return The URL of a file or directory in the format specified above. |
|
665 */ |
|
666 public String getURL() |
|
667 { |
|
668 return null; |
|
669 } |
|
670 |
|
671 /** |
|
672 * Creates a file corresponding to the file string provided constructor of |
|
673 * this FileUtility. The file is created immediately on the actual file |
|
674 * system upon invocation of this method. Files are created with zero length |
|
675 * and data can be put into the file through output streams opened on the |
|
676 * file. This method does not create any directories specified in the file's |
|
677 * path. |
|
678 * |
|
679 * @return true if the file did not exist and was successfully created; |
|
680 * false if the file already existed. |
|
681 * @throws IOException |
|
682 * in case an error occured; or if the URL/Path given during |
|
683 * construction had a trailing "/"(or "\\") to indicate that it |
|
684 * is a directory. |
|
685 * @throws SecurityException |
|
686 * in case the access was denied to create the file |
|
687 */ |
|
688 public boolean createNewFile() throws IOException, SecurityException |
|
689 { |
|
690 return false; |
|
691 } |
|
692 |
|
693 /** |
|
694 * Creates the directory named by this pathname. Directories in the |
|
695 * specified path are not recursively created and must be explicitly created |
|
696 * before sub directories can be created. |
|
697 * |
|
698 * @return true if and only if the directory was created; false if the |
|
699 * directory already existed. |
|
700 * @throws IOException |
|
701 * in case an error occurred; or if the URL/Path given during |
|
702 * construction did not have trailing "/"(or "\\") to indicating |
|
703 * that it is not supposed to be a directory. |
|
704 * @throws SecurityException |
|
705 * in case the access was denied to create the directory |
|
706 */ |
|
707 public boolean mkdir() throws IOException, SecurityException |
|
708 { |
|
709 return false; |
|
710 } |
|
711 |
|
712 /** |
|
713 * Creates the directory named by this pathname, including any necessary but |
|
714 * nonexistent parent directories. Note that if this operation fails it may |
|
715 * have succeeded in creating some of the necessary parent directories. |
|
716 * |
|
717 * @return true if and only if the directory was created, along with all |
|
718 * necessary parent directories; false otherwise |
|
719 * @throws IOException |
|
720 * in case an error occurred |
|
721 * @throws SecurityException |
|
722 */ |
|
723 public boolean mkdirs() throws IOException, SecurityException |
|
724 { |
|
725 |
|
726 return false; |
|
727 } |
|
728 |
|
729 /** |
|
730 * Deletes the file or directory denoted by this pathname. If this pathname |
|
731 * denotes a directory, then the directory must be empty in order to be |
|
732 * deleted. |
|
733 * <p> |
|
734 * All open input and output streams are automatically flushed and closed. |
|
735 * Attempts to further use those streams result in an IOException. The |
|
736 * FileUtility instance object remains available for use. |
|
737 * |
|
738 * @return true if and only if the file or directory is successfully |
|
739 * deleted; false otherwise |
|
740 * @throws SecurityException |
|
741 * if access was denied to the file/directory |
|
742 */ |
|
743 public boolean delete() throws SecurityException |
|
744 { |
|
745 return false; |
|
746 } |
|
747 |
|
748 /** |
|
749 * Deletes the file or directory denoted by this pathname. If this pathname |
|
750 * denotes a directory, then the directory must be empty in order to be |
|
751 * deleted. Deletes the file or directory even if it is marked as read-only. |
|
752 * <p> |
|
753 * All open input and output streams are automatically flushed and closed. |
|
754 * Attempts to further use those streams result in an IOException. The |
|
755 * FileUtility instance object remains available for use. |
|
756 * |
|
757 * @return true if and only if the file or directory is successfully |
|
758 * deleted; false otherwise |
|
759 * @throws SecurityException |
|
760 * if access was denied to the file/directory |
|
761 */ |
|
762 public boolean forceDelete() throws SecurityException |
|
763 { |
|
764 return false; |
|
765 } |
|
766 |
|
767 /** |
|
768 * Renames the selected file or directory to a new name in the same |
|
769 * directory. The file or directory is renamed immediately on the actual |
|
770 * file system upon invocation of this method. No file or directory by the |
|
771 * original name exists after this method call. |
|
772 * <p> |
|
773 * All previously open input and output streams are automatically flushed |
|
774 * and closed. Attempts to further use those streams result in an |
|
775 * IOException. The FileUtility instance object remains open and available |
|
776 * for use, referring now to the file or directory by its new name. |
|
777 * |
|
778 * @param aNewName |
|
779 * new name to which the current iTarget has to be renamed |
|
780 * @return true if rename succeeded, false otherwise |
|
781 * @throws IOException |
|
782 * if the connection's iTarget does not exist, the connection's |
|
783 * iTarget is not accessible, a file or directory already exists |
|
784 * by the newName, or newName is an invalid filename for the |
|
785 * platform (e.g. contains characters invalid in a filename on |
|
786 * the platform) |
|
787 * @throws SecurityException |
|
788 * if access/permission was denied to rename file |
|
789 * @throws IllegalArgumentException |
|
790 * if newName contains any path specification. |
|
791 */ |
|
792 public boolean rename(String aNewName) throws IOException, |
|
793 SecurityException |
|
794 { |
|
795 return false; |
|
796 } |
|
797 |
|
798 /** |
|
799 * Renames the iTarget to new file. Similar to rename, but allows us to |
|
800 * rename files to different paths in the file system. Allows for faster |
|
801 * move within a file system. |
|
802 * |
|
803 * @param aNewName |
|
804 * new path to which it has to be moved. Note that the newName |
|
805 * should be absolute path. |
|
806 * @return true in case rename was successful, false otherwise |
|
807 * @throws IOException |
|
808 * in case some unexpected error occured. |
|
809 */ |
|
810 public boolean renameTo(String aNewName) throws IOException |
|
811 { |
|
812 return false; |
|
813 } |
|
814 |
|
815 public String[] listFileArray(boolean aIncludeHidden) throws IOException |
|
816 { |
|
817 return null; |
|
818 } |
|
819 |
|
820 /** |
|
821 * Gets a filtered list of files and directories contained in a directory |
|
822 * |
|
823 * @param filter |
|
824 * String against which all files and directories are matched for |
|
825 * retrieval. includeHidden: boolean indicating whether files |
|
826 * marked as hidden should be included or not in the list of |
|
827 * files and directories returned. |
|
828 * |
|
829 * @return Vector of strings, denoting the files and directories in the |
|
830 * directory |
|
831 * |
|
832 * @throws IOException |
|
833 * if invoked on a file, the directory does not exist, the |
|
834 * directory is not accessible, or an I/O error occurs. |
|
835 * |
|
836 * @throws SecurityException |
|
837 * if the security of the application does not have read access |
|
838 * for the connection's iTarget. |
|
839 * |
|
840 * @throws IllegalModeException |
|
841 * If application does have read access to the file but has |
|
842 * opened the connection in Connector.WRITE mode. |
|
843 * @throws ConnectionClosedException |
|
844 * If Connection is closed. |
|
845 */ |
|
846 public Vector listFiles(String aFilter, boolean aIncludeHidden) |
|
847 throws IOException |
|
848 { |
|
849 return null; |
|
850 } |
|
851 |
|
852 /** |
|
853 * Gets a filtered list of files and directories contained in a directory |
|
854 * |
|
855 * @param aFilter |
|
856 * String against which all files and directories are matched for |
|
857 * retrieval. includeHidden: boolean indicating whether files |
|
858 * marked as hidden should be included or not in the list of |
|
859 * files and directories returned. |
|
860 * |
|
861 * @return Enumeration of strings, denoting the files and directories in the |
|
862 * directory |
|
863 * |
|
864 * @throws IOException |
|
865 * if invoked on a file, the directory does not exist, the |
|
866 * directory is not accessible, or an I/O error occurs. |
|
867 * SecurityException: if the security of the application does |
|
868 * not have read access for the connection's iTarget. |
|
869 * IllegalModeException: If application does have read access to |
|
870 * the file but has opened the connection in Connector.WRITE |
|
871 * mode. ConnectionClosedException: If Connection is closed. |
|
872 */ |
|
873 public Enumeration list(String aFilter, boolean aIncludeHidden) |
|
874 throws IOException |
|
875 { |
|
876 return null; |
|
877 } |
|
878 |
|
879 /** |
|
880 * Gets a list of all visible files and directories contained in a |
|
881 * directory. The directory is the connection's iTarget as specified in |
|
882 * constructor. |
|
883 * <p> |
|
884 * Any hidden files and directories in the directory are not included in the |
|
885 * returned list. Any current directory indication (".") and any parent |
|
886 * directory indication ("..") is not included in the list of files and |
|
887 * directories returned. |
|
888 * |
|
889 * @return An Enumeration of strings, denoting the files and directories in |
|
890 * the directory. The string returned contain only the file or |
|
891 * directory name and does not contain any path prefix (to get a |
|
892 * complete path for each file or directory, prepend getPath()). |
|
893 * Directories are denoted with a trailing slash "/" in their |
|
894 * returned name. The Enumeration has zero length if the directory |
|
895 * is empty. |
|
896 * @throws IOException |
|
897 */ |
|
898 public Enumeration list() throws IOException |
|
899 { |
|
900 return null; |
|
901 } |
|
902 |
|
903 /** |
|
904 * Gets a list of all visible files and directories contained in a |
|
905 * directory. The directory is the connection's iTarget as specified in |
|
906 * constructor. |
|
907 * <p> |
|
908 * Any hidden files and directories in the directory are not included in the |
|
909 * returned list. Any current directory indication (".") and any parent |
|
910 * directory indication ("..") is not included in the list of files and |
|
911 * directories returned. |
|
912 * |
|
913 * @return An list of FileUtility objects, denoting the files and |
|
914 * directories in the directory. |
|
915 * @throws IOException |
|
916 */ |
|
917 public FileUtility[] listFiles() throws IOException |
|
918 { |
|
919 return null; |
|
920 } |
|
921 |
|
922 /** |
|
923 * Truncates the file, discarding all data from the given byte offset to the |
|
924 * current end of the file |
|
925 * |
|
926 * @param aByteOffset |
|
927 * Offset into the file from which truncation occurs. |
|
928 * |
|
929 * @throws java.io.IOException |
|
930 * if invoked on a directory or the file does not exist or is |
|
931 * not accessible. |
|
932 * @throws SecurityException |
|
933 * if the security of the application does not have write access |
|
934 * for the connection's iTarget. |
|
935 * @throws IllegalArgumentException |
|
936 * if byteOffset is less than zero. |
|
937 */ |
|
938 public void truncate(long aByteOffset) throws java.io.IOException |
|
939 { |
|
940 } |
|
941 |
|
942 |
|
943 public String toString() |
|
944 { |
|
945 return null; |
|
946 } |
|
947 } |