michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsIProtocolHandler.idl" michael@0: michael@0: interface nsIFile; michael@0: michael@0: [scriptable, uuid(1fb25bd5-4354-4dcd-8d97-621b7b3ed2e4)] michael@0: interface nsIFileProtocolHandler : nsIProtocolHandler michael@0: { michael@0: /** michael@0: * This method constructs a new file URI michael@0: * michael@0: * @param aFile nsIFile michael@0: * @return reference to a new nsIURI object michael@0: */ michael@0: nsIURI newFileURI(in nsIFile aFile); michael@0: michael@0: /** michael@0: * Converts the nsIFile to the corresponding URL string. NOTE: under michael@0: * some platforms this is a lossy conversion (e.g., Mac Carbon build). michael@0: * If the nsIFile is a local file, then the result will be a file:// michael@0: * URL string. michael@0: * michael@0: * The resulting string may contain URL-escaped characters. michael@0: * NOTE: Callers should use getURLSpecFromActualFile or michael@0: * getURLSpecFromDirFile if possible, for performance reasons. michael@0: */ michael@0: AUTF8String getURLSpecFromFile(in nsIFile file); michael@0: michael@0: /** michael@0: * Converts the nsIFile to the corresponding URL string. Should michael@0: * only be called on files which are not directories. Otherwise michael@0: * identical to getURLSpecFromFile, but is usually more efficient. michael@0: * WARNING: This restriction may not be enforced at runtime! michael@0: */ michael@0: AUTF8String getURLSpecFromActualFile(in nsIFile file); michael@0: michael@0: /** michael@0: * Converts the nsIFile to the corresponding URL string. Should michael@0: * only be called on files which are directories. Otherwise michael@0: * identical to getURLSpecFromFile, but is usually more efficient. michael@0: * WARNING: This restriction may not be enforced at runtime! michael@0: */ michael@0: AUTF8String getURLSpecFromDir(in nsIFile file); michael@0: michael@0: /** michael@0: * Converts the URL string into the corresponding nsIFile if possible. michael@0: * A local file will be created if the URL string begins with file://. michael@0: */ michael@0: nsIFile getFileFromURLSpec(in AUTF8String url); michael@0: michael@0: /** michael@0: * Takes a local file and tries to interpret it as an internet shortcut michael@0: * (e.g. .url files on windows). michael@0: * @param file The local file to read michael@0: * @return The URI the file refers to michael@0: * michael@0: * @throw NS_ERROR_NOT_AVAILABLE if the OS does not support such files. michael@0: * @throw NS_ERROR_NOT_AVAILABLE if this file is not an internet shortcut. michael@0: */ michael@0: nsIURI readURLFile(in nsIFile file); michael@0: };