|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsIProtocolHandler.idl" |
|
7 |
|
8 interface nsIFile; |
|
9 |
|
10 [scriptable, uuid(1fb25bd5-4354-4dcd-8d97-621b7b3ed2e4)] |
|
11 interface nsIFileProtocolHandler : nsIProtocolHandler |
|
12 { |
|
13 /** |
|
14 * This method constructs a new file URI |
|
15 * |
|
16 * @param aFile nsIFile |
|
17 * @return reference to a new nsIURI object |
|
18 */ |
|
19 nsIURI newFileURI(in nsIFile aFile); |
|
20 |
|
21 /** |
|
22 * Converts the nsIFile to the corresponding URL string. NOTE: under |
|
23 * some platforms this is a lossy conversion (e.g., Mac Carbon build). |
|
24 * If the nsIFile is a local file, then the result will be a file:// |
|
25 * URL string. |
|
26 * |
|
27 * The resulting string may contain URL-escaped characters. |
|
28 * NOTE: Callers should use getURLSpecFromActualFile or |
|
29 * getURLSpecFromDirFile if possible, for performance reasons. |
|
30 */ |
|
31 AUTF8String getURLSpecFromFile(in nsIFile file); |
|
32 |
|
33 /** |
|
34 * Converts the nsIFile to the corresponding URL string. Should |
|
35 * only be called on files which are not directories. Otherwise |
|
36 * identical to getURLSpecFromFile, but is usually more efficient. |
|
37 * WARNING: This restriction may not be enforced at runtime! |
|
38 */ |
|
39 AUTF8String getURLSpecFromActualFile(in nsIFile file); |
|
40 |
|
41 /** |
|
42 * Converts the nsIFile to the corresponding URL string. Should |
|
43 * only be called on files which are directories. Otherwise |
|
44 * identical to getURLSpecFromFile, but is usually more efficient. |
|
45 * WARNING: This restriction may not be enforced at runtime! |
|
46 */ |
|
47 AUTF8String getURLSpecFromDir(in nsIFile file); |
|
48 |
|
49 /** |
|
50 * Converts the URL string into the corresponding nsIFile if possible. |
|
51 * A local file will be created if the URL string begins with file://. |
|
52 */ |
|
53 nsIFile getFileFromURLSpec(in AUTF8String url); |
|
54 |
|
55 /** |
|
56 * Takes a local file and tries to interpret it as an internet shortcut |
|
57 * (e.g. .url files on windows). |
|
58 * @param file The local file to read |
|
59 * @return The URI the file refers to |
|
60 * |
|
61 * @throw NS_ERROR_NOT_AVAILABLE if the OS does not support such files. |
|
62 * @throw NS_ERROR_NOT_AVAILABLE if this file is not an internet shortcut. |
|
63 */ |
|
64 nsIURI readURLFile(in nsIFile file); |
|
65 }; |