1999-10-26 02:45:56 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1999-08-21 11:38:26 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1999-10-26 02:45:56 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code,
|
|
|
|
* released March 31, 1998.
|
1999-08-21 11:38:26 +04:00
|
|
|
*
|
1999-10-26 02:45:56 +04:00
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
1999-11-06 06:43:54 +03:00
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
1999-10-26 02:45:56 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* Contributor(s):
|
1999-10-26 02:45:56 +04:00
|
|
|
* Doug Turner <dougt@netscape.com>
|
1999-08-21 11:38:26 +04:00
|
|
|
*/
|
|
|
|
|
1999-10-26 02:45:56 +04:00
|
|
|
|
1999-08-21 11:38:26 +04:00
|
|
|
// This is the only correct cross-platform way to specify a file.
|
|
|
|
// Strings are not such a way. If you grew up on windows or unix, you
|
|
|
|
// may think they are. Welcome to reality.
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
|
|
|
[scriptable, uuid(c8c0a080-0868-11d3-915f-d9d889d48e3c)]
|
|
|
|
interface nsIFile : nsISupports
|
|
|
|
{
|
1999-08-25 01:51:32 +04:00
|
|
|
|
|
|
|
/**
|
1999-09-02 03:51:11 +04:00
|
|
|
* Create Types
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
|
|
|
* NORMAL_FILE_TYPE - A normal file.
|
|
|
|
* DIRECTORY_TYPE - A directory/folder.
|
1999-09-02 03:51:11 +04:00
|
|
|
*/
|
|
|
|
const unsigned long NORMAL_FILE_TYPE = 0;
|
|
|
|
const unsigned long DIRECTORY_TYPE = 1;
|
|
|
|
|
1999-10-23 08:51:35 +04:00
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
1999-10-23 08:51:35 +04:00
|
|
|
* appendPath
|
|
|
|
*
|
|
|
|
* This function is used for constructing a descendat of the
|
|
|
|
* current nsIFile. Non-terminal nodes will be resolved. An
|
|
|
|
* error will be returned if a non-terminal is a file
|
|
|
|
* (NS_ERROR_FILE_INVALID_PATH).
|
|
|
|
*
|
|
|
|
* @param relativePath
|
|
|
|
* A unix style string which is intented to be a relative
|
|
|
|
* path of the nsIFile. Starting and trailing '/' will
|
|
|
|
* be ignored. If this path is not a unix style path, an
|
|
|
|
* error will be returned (NS_ERROR_FILE_UNRECONGNIZED_PATH).
|
1999-09-02 03:51:11 +04:00
|
|
|
*/
|
1999-10-23 08:51:35 +04:00
|
|
|
|
|
|
|
void appendPath([const] in string relativePath);
|
|
|
|
|
1999-11-29 17:55:03 +03:00
|
|
|
/**
|
|
|
|
* Normalize the pathName (e.g. removing .. and . components on Unix).
|
|
|
|
*/
|
|
|
|
void normalize();
|
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
1999-10-23 08:51:35 +04:00
|
|
|
* create
|
1999-09-02 03:51:11 +04:00
|
|
|
*
|
1999-10-23 08:51:35 +04:00
|
|
|
* This function will create a new file or directory in the
|
|
|
|
* file system. Any nodes that have not been created or
|
|
|
|
* resolved, will be. If the file or directory already
|
|
|
|
* exists create() will return NS_ERROR_FILE_ALREADY_EXISTS.
|
|
|
|
*
|
|
|
|
* @param type
|
|
|
|
* This specifies the type of file system object
|
|
|
|
* to be made. The only two types at this time
|
|
|
|
* are file and directory which are defined above.
|
|
|
|
* If the type is unrecongnized, we will return an
|
|
|
|
* error (NS_ERROR_FILE_UNKNOWN_TYPE).
|
|
|
|
*
|
|
|
|
* @param permissions
|
|
|
|
* This unix style octal permissions. This may
|
|
|
|
* be ignored on systems that do not need to do
|
|
|
|
* permissions.
|
1999-09-02 03:51:11 +04:00
|
|
|
*/
|
1999-10-23 08:51:35 +04:00
|
|
|
|
|
|
|
void create(in unsigned long type, in unsigned long permissions);
|
|
|
|
|
1999-08-24 04:47:02 +04:00
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
1999-11-29 17:55:03 +03:00
|
|
|
* Accessor to the leaf name of the file itself.
|
1999-09-02 03:51:11 +04:00
|
|
|
*/
|
1999-12-02 04:19:10 +03:00
|
|
|
readonly attribute string leafName;
|
1999-09-02 03:51:11 +04:00
|
|
|
|
|
|
|
/**
|
1999-10-23 08:51:35 +04:00
|
|
|
* copyTo
|
|
|
|
*
|
|
|
|
* This will copy this file to the specified newParentDir.
|
1999-09-02 03:51:11 +04:00
|
|
|
* If a newName is specified, the file will be renamed.
|
1999-10-23 08:51:35 +04:00
|
|
|
* If 'this' is not created we will return an error
|
|
|
|
* (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST).
|
|
|
|
*
|
1999-12-02 04:19:10 +03:00
|
|
|
* copyTo will NOT resolve aliases/shortcuts during the copy.
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
|
|
|
* @param newParentDir
|
|
|
|
* This param is the destination directory. If the
|
|
|
|
* newParentDir is nsnull, copyTo() will simply
|
|
|
|
* rename the file. If the newParentDir is not
|
|
|
|
* null and does not exists, an error will be
|
|
|
|
* returned (NS_ERROR_FILE_DESTINATION_NOT_DIR)
|
|
|
|
*
|
|
|
|
* @param newName
|
|
|
|
* This param allows you to specify a new name
|
|
|
|
* for the file to be copied. This can be nsnull.
|
1999-09-02 03:51:11 +04:00
|
|
|
*
|
1999-12-02 04:19:10 +03:00
|
|
|
*/
|
1999-10-23 08:51:35 +04:00
|
|
|
|
|
|
|
void copyTo(in nsIFile newParentDir, [const] in string newName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* copyToFollowingLinks
|
|
|
|
*
|
|
|
|
* This function is identical to copyTo except it, as
|
|
|
|
* the name implies, follows symbolic links.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void copyToFollowingLinks(in nsIFile newParentDir, [const] in string newName);
|
1999-09-02 03:51:11 +04:00
|
|
|
|
|
|
|
/**
|
1999-10-23 08:51:35 +04:00
|
|
|
* moveTo
|
1999-09-02 03:51:11 +04:00
|
|
|
*
|
1999-10-23 08:51:35 +04:00
|
|
|
* This will move this file to the specified newParentDir.
|
1999-09-02 03:51:11 +04:00
|
|
|
* If a newName is specified, the file will be renamed.
|
1999-10-23 08:51:35 +04:00
|
|
|
* If 'this' is not created we will return an error
|
|
|
|
* (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST).
|
|
|
|
*
|
1999-12-02 04:19:10 +03:00
|
|
|
* moveTo will NOT resolve aliases/shortcuts during the copy.
|
1999-10-23 08:51:35 +04:00
|
|
|
* moveTo will do the right thing and allow copies across
|
|
|
|
* volumes.
|
|
|
|
*
|
|
|
|
* @param newParentDir
|
|
|
|
* This param is the destination directory. If the
|
|
|
|
* newParentDir is nsnull, moveTo() will simply
|
|
|
|
* rename the file. If the newParentDir is not
|
|
|
|
* null and does not exists, an error will be
|
|
|
|
* returned (NS_ERROR_FILE_DESTINATION_NOT_DIR)
|
|
|
|
*
|
|
|
|
* @param newName
|
|
|
|
* This param allows you to specify a new name
|
|
|
|
* for the file to be moved. This can be nsnull.
|
1999-09-02 03:51:11 +04:00
|
|
|
*
|
1999-12-02 04:19:10 +03:00
|
|
|
*/
|
|
|
|
void moveTo(in nsIFile newParentDir, [const] in string newName);
|
1999-10-23 08:51:35 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* moveToFollowingLinks
|
|
|
|
*
|
|
|
|
* This function is identical to moveTo except it, as
|
|
|
|
* the name implies, follows symbolic links.
|
1999-09-02 03:51:11 +04:00
|
|
|
*/
|
1999-10-23 08:51:35 +04:00
|
|
|
|
1999-12-02 04:19:10 +03:00
|
|
|
void moveToFollowingLinks(in nsIFile newParentDir, [const] in string newName);
|
1999-09-02 03:51:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This will try to execute this file. It will not block for
|
|
|
|
* execution. 'args' will be passed through on the command line
|
|
|
|
* if the OS supports that.
|
|
|
|
*/
|
1999-12-02 04:19:10 +03:00
|
|
|
void spawn([const] in string args);
|
1999-09-02 03:51:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This will try to delete this file. The 'recursive' flag
|
|
|
|
* must be PR_TRUE to delete directories which are not empty.
|
|
|
|
*
|
|
|
|
* This will not resolve any symlinks.
|
|
|
|
*/
|
1999-12-02 04:19:10 +03:00
|
|
|
void delete(in boolean recursive);
|
1999-08-21 11:38:26 +04:00
|
|
|
|
1999-11-29 17:55:03 +03:00
|
|
|
/**
|
|
|
|
* Truncate the file to the given length.
|
|
|
|
*/
|
1999-12-02 04:19:10 +03:00
|
|
|
void truncate(in unsigned long length);
|
1999-11-29 17:55:03 +03:00
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
|
|
|
* Attributes of nsIFile.
|
|
|
|
*/
|
1999-12-02 04:19:10 +03:00
|
|
|
|
|
|
|
attribute unsigned long permissions;
|
|
|
|
attribute unsigned long permissionsOfLink;
|
|
|
|
|
|
|
|
attribute PRInt64 lastModificationDate;
|
|
|
|
attribute PRInt64 lastModificationDateOfLink;
|
|
|
|
|
|
|
|
attribute PRInt64 fileSize;
|
|
|
|
readonly attribute PRInt64 fileSizeOfLink;
|
|
|
|
|
1999-11-29 17:55:03 +03:00
|
|
|
/**
|
1999-12-02 04:19:10 +03:00
|
|
|
* target & path
|
|
|
|
*
|
|
|
|
* Accessor to the string path. These strings are
|
|
|
|
* not guaranteed to be a usable path to pass to NSPR
|
|
|
|
* or the C stdlib. There are problem which affects
|
|
|
|
* platforms in which a path does not fully specify a
|
|
|
|
* file, because two volumes can have the same name.
|
|
|
|
* This is solved by holding a "private" native data.
|
|
|
|
* This data is lost when you convert to a string.
|
|
|
|
*
|
|
|
|
* DO NOT PASS TO USE WITH NSPR OR STDLIB.
|
|
|
|
*
|
|
|
|
* target:
|
|
|
|
* Find out what the symlink points at. Will give error
|
|
|
|
* (NS_ERROR_FILE_INVALID_PATH) if not a symlink.
|
|
|
|
*
|
|
|
|
* path:
|
|
|
|
* Find out what the nsIFile points at.
|
1999-11-29 17:55:03 +03:00
|
|
|
*/
|
1999-09-02 03:51:11 +04:00
|
|
|
|
1999-12-02 04:19:10 +03:00
|
|
|
readonly attribute string target;
|
|
|
|
readonly attribute string path;
|
|
|
|
|
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
|
|
|
* Parent will be nsnull when this is at the top of the volume.
|
|
|
|
*/
|
1999-12-02 04:19:10 +03:00
|
|
|
readonly attribute nsIFile parent;
|
1999-09-02 03:51:11 +04:00
|
|
|
|
1999-12-02 04:19:10 +03:00
|
|
|
boolean exists();
|
|
|
|
boolean isWritable();
|
|
|
|
boolean isReadable();
|
|
|
|
boolean isExecutable();
|
|
|
|
boolean isHidden();
|
|
|
|
boolean isDirectory();
|
|
|
|
boolean isFile();
|
|
|
|
boolean isSymlink();
|
1999-11-29 17:55:03 +03:00
|
|
|
/**
|
|
|
|
* Not a regular file, not a directory, not a symlink.
|
|
|
|
*/
|
1999-12-02 04:19:10 +03:00
|
|
|
boolean isSpecial();
|
1999-09-02 03:51:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Will determine if the inFile equals this.
|
|
|
|
*/
|
1999-12-02 04:19:10 +03:00
|
|
|
boolean equals(in nsIFile inFile);
|
1999-10-23 08:51:35 +04:00
|
|
|
|
|
|
|
/**
|
1999-11-29 17:55:03 +03:00
|
|
|
* Will determine the file is a descendant of the parameter inFile.
|
|
|
|
* If |recur| is true, it will descend subdirectories looking for
|
1999-10-23 08:51:35 +04:00
|
|
|
*/
|
1999-12-02 04:19:10 +03:00
|
|
|
boolean isContainedIn(in nsIFile inFile, in boolean recur);
|
1999-08-21 11:38:26 +04:00
|
|
|
};
|
1999-09-09 00:12:35 +04:00
|
|
|
|
|
|
|
%{C++
|
|
|
|
#define NS_FILE_PROGID "component://netscape/file"
|
|
|
|
#define NS_FILE_CLASSNAME "File Specification"
|
1999-10-23 08:51:35 +04:00
|
|
|
|
1999-11-29 17:55:03 +03:00
|
|
|
#define NS_ERROR_FILE_UNRECOGNIZED_PATH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 1)
|
1999-10-23 08:51:35 +04:00
|
|
|
#define NS_ERROR_FILE_UNRESOLVABLE_SYMLINK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 2)
|
|
|
|
#define NS_ERROR_FILE_EXECUTION_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 3)
|
|
|
|
#define NS_ERROR_FILE_UNKNOWN_TYPE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 4)
|
|
|
|
#define NS_ERROR_FILE_DESTINATION_NOT_DIR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 5)
|
|
|
|
#define NS_ERROR_FILE_TARGET_DOES_NOT_EXIST NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 6)
|
|
|
|
#define NS_ERROR_FILE_COPY_OR_MOVE_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 7)
|
|
|
|
#define NS_ERROR_FILE_ALREADY_EXISTS NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 8)
|
|
|
|
#define NS_ERROR_FILE_INVALID_PATH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 9)
|
1999-11-30 07:50:42 +03:00
|
|
|
#define NS_ERROR_FILE_DISK_FULL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 10)
|
|
|
|
#define NS_ERROR_FILE_CORRUPTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 11)
|
1999-11-01 07:44:56 +03:00
|
|
|
%}
|