2002-01-30 00:42:38 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-08-21 11:38:26 +04:00
|
|
|
|
2002-05-03 10:01:29 +04:00
|
|
|
#include "nsISupports.idl"
|
2018-05-18 01:06:48 +03:00
|
|
|
#include "nsIDirectoryEnumerator.idl"
|
2002-05-03 10:01:29 +04:00
|
|
|
|
2012-04-04 15:04:37 +04:00
|
|
|
%{C++
|
2013-09-23 21:29:27 +04:00
|
|
|
struct PRFileDesc;
|
|
|
|
struct PRLibrary;
|
2012-04-04 15:04:37 +04:00
|
|
|
#include <stdio.h>
|
2017-12-27 21:03:35 +03:00
|
|
|
#include "mozilla/Path.h"
|
2018-05-18 01:06:48 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2017-12-27 21:03:35 +03:00
|
|
|
#include "nsStringFwd.h"
|
|
|
|
namespace mozilla {
|
|
|
|
using PathString = nsTString<filesystem::Path::value_type>;
|
|
|
|
using PathSubstring = nsTSubstring<filesystem::Path::value_type>;
|
|
|
|
} // namespace mozilla
|
2012-04-04 15:04:37 +04:00
|
|
|
%}
|
|
|
|
|
|
|
|
[ptr] native PRFileDescStar(PRFileDesc);
|
|
|
|
[ptr] native PRLibraryStar(PRLibrary);
|
|
|
|
[ptr] native FILE(FILE);
|
2017-12-27 21:03:35 +03:00
|
|
|
native PathString(mozilla::PathString);
|
2012-04-04 15:04:37 +04:00
|
|
|
|
2001-03-24 03:22:18 +03:00
|
|
|
/**
|
2013-09-06 19:06:23 +04:00
|
|
|
* An nsIFile is an abstract representation of a filename. It manages
|
|
|
|
* filename encoding issues, pathname component separators ('/' vs. '\\'
|
|
|
|
* vs. ':') and weird stuff like differing volumes with identical names, as
|
|
|
|
* on pre-Darwin Macintoshes.
|
|
|
|
*
|
|
|
|
* This file has long introduced itself to new hackers with this opening
|
|
|
|
* paragraph:
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* While taking the pose struck here to heart would be uncalled for, one
|
|
|
|
* may safely conclude that writing cross-platform code is an embittering
|
|
|
|
* experience.
|
2002-05-03 10:01:29 +04:00
|
|
|
*
|
|
|
|
* All methods with string parameters have two forms. The preferred
|
2002-05-08 03:07:19 +04:00
|
|
|
* form operates on UCS-2 encoded characters strings. An alternate
|
2002-05-03 10:01:29 +04:00
|
|
|
* form operates on characters strings encoded in the "native" charset.
|
|
|
|
*
|
|
|
|
* A string containing characters encoded in the native charset cannot
|
|
|
|
* be safely passed to javascript via xpconnect. Therefore, the "native
|
2013-09-06 19:06:23 +04:00
|
|
|
* methods" are not scriptable.
|
2001-03-24 03:22:18 +03:00
|
|
|
*/
|
2015-06-17 23:17:20 +03:00
|
|
|
[scriptable, main_process_scriptable_only, uuid(2fa6884a-ae65-412a-9d4c-ce6e34544ba1), builtinclass]
|
1999-08-21 11:38:26 +04:00
|
|
|
interface nsIFile : nsISupports
|
|
|
|
{
|
1999-08-25 01:51:32 +04:00
|
|
|
/**
|
2002-05-03 10:01:29 +04:00
|
|
|
* Create Types
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
2002-05-03 10:01:29 +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;
|
2000-05-15 10:41:00 +04:00
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
2002-05-03 10:01:29 +04:00
|
|
|
* append[Native]
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
2002-05-03 10:01:29 +04:00
|
|
|
* This function is used for constructing a descendent of the
|
2000-05-15 10:41:00 +04:00
|
|
|
* current nsIFile.
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
2002-05-03 10:01:29 +04:00
|
|
|
* @param node
|
|
|
|
* A string which is intended to be a child node of the nsIFile.
|
2002-06-11 23:26:04 +04:00
|
|
|
* For the |appendNative| method, the node must be in the native
|
|
|
|
* filesystem charset.
|
1999-09-02 03:51:11 +04:00
|
|
|
*/
|
2002-05-08 03:07:19 +04:00
|
|
|
void append(in AString node);
|
2002-04-27 09:33:09 +04:00
|
|
|
[noscript] void appendNative(in ACString node);
|
1999-10-23 08:51:35 +04:00
|
|
|
|
2000-01-25 00:28:28 +03:00
|
|
|
/**
|
2002-05-03 10:01:29 +04:00
|
|
|
* Normalize the pathName (e.g. removing .. and . components on Unix).
|
2000-01-25 00:28:28 +03:00
|
|
|
*/
|
1999-12-03 00:45:50 +03:00
|
|
|
void normalize();
|
1999-11-29 17:55:03 +03:00
|
|
|
|
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
|
|
|
*
|
2000-05-15 10:41:00 +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
|
1999-10-23 08:51:35 +04:00
|
|
|
* exists create() will return NS_ERROR_FILE_ALREADY_EXISTS.
|
2000-05-15 10:41:00 +04:00
|
|
|
*
|
1999-10-23 08:51:35 +04:00
|
|
|
* @param type
|
1999-12-03 00:45:50 +03:00
|
|
|
* 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).
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
|
|
|
* @param permissions
|
2000-06-24 05:50:53 +04:00
|
|
|
* The unix style octal permissions. This may
|
1999-12-03 00:45:50 +03:00
|
|
|
* be ignored on systems that do not need to do
|
|
|
|
* permissions.
|
1999-09-02 03:51:11 +04:00
|
|
|
*/
|
2016-08-18 06:30:12 +03:00
|
|
|
[must_use] void create(in unsigned long type, in unsigned long permissions);
|
1999-10-23 08:51:35 +04:00
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
2002-06-11 23:26:04 +04:00
|
|
|
* Accessor to the leaf name of the file itself.
|
|
|
|
* For the |nativeLeafName| method, the nativeLeafName must
|
|
|
|
* be in the native filesystem charset.
|
1999-09-02 03:51:11 +04:00
|
|
|
*/
|
2002-05-08 03:07:19 +04:00
|
|
|
attribute AString leafName;
|
2002-04-27 09:33:09 +04:00
|
|
|
[noscript] attribute ACString nativeLeafName;
|
2000-05-15 10:41:00 +04:00
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
2002-05-03 10:01:29 +04:00
|
|
|
* copyTo[Native]
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
2000-05-15 10:41:00 +04:00
|
|
|
* 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.
|
2000-05-15 10:41:00 +04:00
|
|
|
* If 'this' is not created we will return an error
|
1999-10-23 08:51:35 +04:00
|
|
|
* (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST).
|
|
|
|
*
|
2002-03-08 03:05:34 +03:00
|
|
|
* copyTo may fail if the file already exists in the destination
|
|
|
|
* directory.
|
|
|
|
*
|
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
|
2000-05-15 10:41:00 +04:00
|
|
|
* This param is the destination directory. If the
|
2002-05-07 02:45:30 +04:00
|
|
|
* newParentDir is null, copyTo() will use the parent
|
Fixes to use atomic rename(2) if possible in nsLocalFile::MoveTo (33098, r=?),
plus a bunch of other fixes and cleanups:
- Fix comment misstatements of fact in nsIFile.idl, improve style slightly.
- Fix typo in comment in nsILocalFile.idl.
- Avoid gratuitous nsCString and nsXPIDLCString copy-constructions, which
entail malloc'ing, in nsLocalFileUnix.cpp's CopyTo and GetParent methods.
But do use nsXPIDLCString instead of raw nsMemory::Alloc/Free.
- Get rid of unnecessary mLL_II2L and mLL_L2II macros, use "prlong.h" API only.
Also use the LL_* macros consistently in case a Unix lacking long long type
support wants to use this code.
* BTW, the "Date" methods should be renamed to use "Time" instead -- after all
PRTime is the type, and traditionally "time" refers to the time-number, a
scalar independent of one's position on the surface of the earth, while
"date" refers to a struct full of locale-specific information derived from
time and some "environment" variables such as DST. Can we rename these
nsIFile methods before Mozilla 0.9 / Netscape 6?
- Use CHECK_mPath consistently and first, before any assertions relating to
arguments (which logically come after the 'this' parameter CHECK_mPath is
making assertions about).
- Use nsCOMPtr for singly-inheriting implementations of XPCOM interfaces, to
avoid scary-when-scaled 0-refcnt instances from being handled (these all
got a ref via QI or equivalent soon enough, but you never know). This also
removed some naked deletes.
- Canonize all paths copied into mPath to lack trailing slashes, so we don't
need to strip trailing slashes elsewhere, in higher-frequency methods (you
set path less often than you get it or a substring of it).
- ssize_t for strlen return values.
- Since shaver used a function pointer to consolidate creat/mkdir logic, but
didn't fold the necessary close of the new fd returned by non-failing creat
into the pointed-at function, I did that.
- AppendRelativePath forbids .. as a component (bounded by / or beginning or
end of string on either side), not just in the middle of fragment (so that
foo..bar is not an illegal relative pathname -- it should not be). BTW,
what the heck is the difference between NS_ERROR_FILE_UNRECOGNIZED_PATH and
...INVALID_PATH?
- SetLeafName was overallocating the new pathname buffer by failing to subtract
the old leafname's length.
- CopyTo was failing to return an NSRESULT_FOR_ERRNO(), it just called that
macro on a line by itself -- eek! It also contained redundant if (newFD
== nsnull) {...} cleanup code, it did a useless PR_GetFileInfo call, and it
leaked FDs on read or write error.
- Implemented CopyToFollowingLinks as a forwarded call to CopyTo, Unix does
not support "copying" a symlink via normal file i/o. Should we instead
lstat in CopyTo and if a link is the source of the copy, do readlink and
then symlink?
- Fixed the readlink method (GetTarget) to null-terminate the link string in
the out parameter (readlink does not do that for you).
- Lots of little nsnull vs. NULL vs. 0, == and != applied to boolean or null
literals, white-space, indentation, bracing, comment, and sloppy code order
(e.g., declaring an initialized variable that's not used till after early
returns) fixes. Also invert some return logic so that NS_OK is the normal,
least indented, final return.
2000-09-19 04:22:41 +04:00
|
|
|
* directory of this file. If the newParentDir is not
|
2002-05-03 10:01:29 +04:00
|
|
|
* empty and is not a directory, an error will be
|
2002-06-11 23:26:04 +04:00
|
|
|
* returned (NS_ERROR_FILE_DESTINATION_NOT_DIR). For the
|
|
|
|
* |CopyToNative| method, the newName must be in the
|
|
|
|
* native filesystem charset.
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
|
|
|
* @param newName
|
Fixes to use atomic rename(2) if possible in nsLocalFile::MoveTo (33098, r=?),
plus a bunch of other fixes and cleanups:
- Fix comment misstatements of fact in nsIFile.idl, improve style slightly.
- Fix typo in comment in nsILocalFile.idl.
- Avoid gratuitous nsCString and nsXPIDLCString copy-constructions, which
entail malloc'ing, in nsLocalFileUnix.cpp's CopyTo and GetParent methods.
But do use nsXPIDLCString instead of raw nsMemory::Alloc/Free.
- Get rid of unnecessary mLL_II2L and mLL_L2II macros, use "prlong.h" API only.
Also use the LL_* macros consistently in case a Unix lacking long long type
support wants to use this code.
* BTW, the "Date" methods should be renamed to use "Time" instead -- after all
PRTime is the type, and traditionally "time" refers to the time-number, a
scalar independent of one's position on the surface of the earth, while
"date" refers to a struct full of locale-specific information derived from
time and some "environment" variables such as DST. Can we rename these
nsIFile methods before Mozilla 0.9 / Netscape 6?
- Use CHECK_mPath consistently and first, before any assertions relating to
arguments (which logically come after the 'this' parameter CHECK_mPath is
making assertions about).
- Use nsCOMPtr for singly-inheriting implementations of XPCOM interfaces, to
avoid scary-when-scaled 0-refcnt instances from being handled (these all
got a ref via QI or equivalent soon enough, but you never know). This also
removed some naked deletes.
- Canonize all paths copied into mPath to lack trailing slashes, so we don't
need to strip trailing slashes elsewhere, in higher-frequency methods (you
set path less often than you get it or a substring of it).
- ssize_t for strlen return values.
- Since shaver used a function pointer to consolidate creat/mkdir logic, but
didn't fold the necessary close of the new fd returned by non-failing creat
into the pointed-at function, I did that.
- AppendRelativePath forbids .. as a component (bounded by / or beginning or
end of string on either side), not just in the middle of fragment (so that
foo..bar is not an illegal relative pathname -- it should not be). BTW,
what the heck is the difference between NS_ERROR_FILE_UNRECOGNIZED_PATH and
...INVALID_PATH?
- SetLeafName was overallocating the new pathname buffer by failing to subtract
the old leafname's length.
- CopyTo was failing to return an NSRESULT_FOR_ERRNO(), it just called that
macro on a line by itself -- eek! It also contained redundant if (newFD
== nsnull) {...} cleanup code, it did a useless PR_GetFileInfo call, and it
leaked FDs on read or write error.
- Implemented CopyToFollowingLinks as a forwarded call to CopyTo, Unix does
not support "copying" a symlink via normal file i/o. Should we instead
lstat in CopyTo and if a link is the source of the copy, do readlink and
then symlink?
- Fixed the readlink method (GetTarget) to null-terminate the link string in
the out parameter (readlink does not do that for you).
- Lots of little nsnull vs. NULL vs. 0, == and != applied to boolean or null
literals, white-space, indentation, bracing, comment, and sloppy code order
(e.g., declaring an initialized variable that's not used till after early
returns) fixes. Also invert some return logic so that NS_OK is the normal,
least indented, final return.
2000-09-19 04:22:41 +04:00
|
|
|
* This param allows you to specify a new name for
|
2002-05-03 10:01:29 +04:00
|
|
|
* the file to be copied. This param may be empty, in
|
Fixes to use atomic rename(2) if possible in nsLocalFile::MoveTo (33098, r=?),
plus a bunch of other fixes and cleanups:
- Fix comment misstatements of fact in nsIFile.idl, improve style slightly.
- Fix typo in comment in nsILocalFile.idl.
- Avoid gratuitous nsCString and nsXPIDLCString copy-constructions, which
entail malloc'ing, in nsLocalFileUnix.cpp's CopyTo and GetParent methods.
But do use nsXPIDLCString instead of raw nsMemory::Alloc/Free.
- Get rid of unnecessary mLL_II2L and mLL_L2II macros, use "prlong.h" API only.
Also use the LL_* macros consistently in case a Unix lacking long long type
support wants to use this code.
* BTW, the "Date" methods should be renamed to use "Time" instead -- after all
PRTime is the type, and traditionally "time" refers to the time-number, a
scalar independent of one's position on the surface of the earth, while
"date" refers to a struct full of locale-specific information derived from
time and some "environment" variables such as DST. Can we rename these
nsIFile methods before Mozilla 0.9 / Netscape 6?
- Use CHECK_mPath consistently and first, before any assertions relating to
arguments (which logically come after the 'this' parameter CHECK_mPath is
making assertions about).
- Use nsCOMPtr for singly-inheriting implementations of XPCOM interfaces, to
avoid scary-when-scaled 0-refcnt instances from being handled (these all
got a ref via QI or equivalent soon enough, but you never know). This also
removed some naked deletes.
- Canonize all paths copied into mPath to lack trailing slashes, so we don't
need to strip trailing slashes elsewhere, in higher-frequency methods (you
set path less often than you get it or a substring of it).
- ssize_t for strlen return values.
- Since shaver used a function pointer to consolidate creat/mkdir logic, but
didn't fold the necessary close of the new fd returned by non-failing creat
into the pointed-at function, I did that.
- AppendRelativePath forbids .. as a component (bounded by / or beginning or
end of string on either side), not just in the middle of fragment (so that
foo..bar is not an illegal relative pathname -- it should not be). BTW,
what the heck is the difference between NS_ERROR_FILE_UNRECOGNIZED_PATH and
...INVALID_PATH?
- SetLeafName was overallocating the new pathname buffer by failing to subtract
the old leafname's length.
- CopyTo was failing to return an NSRESULT_FOR_ERRNO(), it just called that
macro on a line by itself -- eek! It also contained redundant if (newFD
== nsnull) {...} cleanup code, it did a useless PR_GetFileInfo call, and it
leaked FDs on read or write error.
- Implemented CopyToFollowingLinks as a forwarded call to CopyTo, Unix does
not support "copying" a symlink via normal file i/o. Should we instead
lstat in CopyTo and if a link is the source of the copy, do readlink and
then symlink?
- Fixed the readlink method (GetTarget) to null-terminate the link string in
the out parameter (readlink does not do that for you).
- Lots of little nsnull vs. NULL vs. 0, == and != applied to boolean or null
literals, white-space, indentation, bracing, comment, and sloppy code order
(e.g., declaring an initialized variable that's not used till after early
returns) fixes. Also invert some return logic so that NS_OK is the normal,
least indented, final return.
2000-09-19 04:22:41 +04:00
|
|
|
* which case the current leaf name will be used.
|
1999-12-02 04:19:10 +03:00
|
|
|
*/
|
2002-05-08 03:07:19 +04:00
|
|
|
void copyTo(in nsIFile newParentDir, in AString newName);
|
2002-06-14 00:13:17 +04:00
|
|
|
[noscript] void CopyToNative(in nsIFile newParentDir, in ACString newName);
|
2000-05-15 10:41:00 +04:00
|
|
|
|
1999-10-23 08:51:35 +04:00
|
|
|
/**
|
2002-05-03 10:01:29 +04:00
|
|
|
* copyToFollowingLinks[Native]
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
2002-05-03 10:01:29 +04:00
|
|
|
* This function is identical to copyTo with the exception that,
|
|
|
|
* as the name implies, it follows symbolic links. The XP_UNIX
|
2002-06-11 23:26:04 +04:00
|
|
|
* implementation always follow symbolic links when copying. For
|
|
|
|
* the |CopyToFollowingLinks| method, the newName must be in the
|
|
|
|
* native filesystem charset.
|
1999-10-23 08:51:35 +04:00
|
|
|
*/
|
2002-05-08 03:07:19 +04:00
|
|
|
void copyToFollowingLinks(in nsIFile newParentDir, in AString newName);
|
2002-04-27 09:33:09 +04:00
|
|
|
[noscript] void copyToFollowingLinksNative(in nsIFile newParentDir, in ACString newName);
|
2000-05-15 10:41:00 +04:00
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
2002-05-03 10:01:29 +04:00
|
|
|
* moveTo[Native]
|
1999-09-02 03:51:11 +04:00
|
|
|
*
|
2002-11-13 17:04:51 +03:00
|
|
|
* A method to move this file or directory to newParentDir.
|
|
|
|
* If a newName is specified, the file or directory will be renamed.
|
2000-05-15 10:41:00 +04:00
|
|
|
* If 'this' is not created we will return an error
|
1999-10-23 08:51:35 +04:00
|
|
|
* (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST).
|
2002-11-13 17:04:51 +03:00
|
|
|
* If 'this' is a file, and the destination file already exists, moveTo
|
|
|
|
* will replace the old file.
|
2009-03-24 03:44:37 +03:00
|
|
|
* This object is updated to refer to the new file.
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
1999-12-02 04:19:10 +03:00
|
|
|
* moveTo will NOT resolve aliases/shortcuts during the copy.
|
2002-11-13 17:04:51 +03:00
|
|
|
* moveTo will do the right thing and allow copies across volumes.
|
|
|
|
* moveTo will return an error (NS_ERROR_FILE_DIR_NOT_EMPTY) if 'this' is
|
|
|
|
* a directory and the destination directory is not empty.
|
|
|
|
* moveTo will return an error (NS_ERROR_FILE_ACCESS_DENIED) if 'this' is
|
|
|
|
* a directory and the destination directory is not writable.
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
|
|
|
* @param newParentDir
|
2000-05-15 10:41:00 +04:00
|
|
|
* This param is the destination directory. If the
|
2002-05-03 10:01:29 +04:00
|
|
|
* newParentDir is empty, moveTo() will rename the file
|
Fixes to use atomic rename(2) if possible in nsLocalFile::MoveTo (33098, r=?),
plus a bunch of other fixes and cleanups:
- Fix comment misstatements of fact in nsIFile.idl, improve style slightly.
- Fix typo in comment in nsILocalFile.idl.
- Avoid gratuitous nsCString and nsXPIDLCString copy-constructions, which
entail malloc'ing, in nsLocalFileUnix.cpp's CopyTo and GetParent methods.
But do use nsXPIDLCString instead of raw nsMemory::Alloc/Free.
- Get rid of unnecessary mLL_II2L and mLL_L2II macros, use "prlong.h" API only.
Also use the LL_* macros consistently in case a Unix lacking long long type
support wants to use this code.
* BTW, the "Date" methods should be renamed to use "Time" instead -- after all
PRTime is the type, and traditionally "time" refers to the time-number, a
scalar independent of one's position on the surface of the earth, while
"date" refers to a struct full of locale-specific information derived from
time and some "environment" variables such as DST. Can we rename these
nsIFile methods before Mozilla 0.9 / Netscape 6?
- Use CHECK_mPath consistently and first, before any assertions relating to
arguments (which logically come after the 'this' parameter CHECK_mPath is
making assertions about).
- Use nsCOMPtr for singly-inheriting implementations of XPCOM interfaces, to
avoid scary-when-scaled 0-refcnt instances from being handled (these all
got a ref via QI or equivalent soon enough, but you never know). This also
removed some naked deletes.
- Canonize all paths copied into mPath to lack trailing slashes, so we don't
need to strip trailing slashes elsewhere, in higher-frequency methods (you
set path less often than you get it or a substring of it).
- ssize_t for strlen return values.
- Since shaver used a function pointer to consolidate creat/mkdir logic, but
didn't fold the necessary close of the new fd returned by non-failing creat
into the pointed-at function, I did that.
- AppendRelativePath forbids .. as a component (bounded by / or beginning or
end of string on either side), not just in the middle of fragment (so that
foo..bar is not an illegal relative pathname -- it should not be). BTW,
what the heck is the difference between NS_ERROR_FILE_UNRECOGNIZED_PATH and
...INVALID_PATH?
- SetLeafName was overallocating the new pathname buffer by failing to subtract
the old leafname's length.
- CopyTo was failing to return an NSRESULT_FOR_ERRNO(), it just called that
macro on a line by itself -- eek! It also contained redundant if (newFD
== nsnull) {...} cleanup code, it did a useless PR_GetFileInfo call, and it
leaked FDs on read or write error.
- Implemented CopyToFollowingLinks as a forwarded call to CopyTo, Unix does
not support "copying" a symlink via normal file i/o. Should we instead
lstat in CopyTo and if a link is the source of the copy, do readlink and
then symlink?
- Fixed the readlink method (GetTarget) to null-terminate the link string in
the out parameter (readlink does not do that for you).
- Lots of little nsnull vs. NULL vs. 0, == and != applied to boolean or null
literals, white-space, indentation, bracing, comment, and sloppy code order
(e.g., declaring an initialized variable that's not used till after early
returns) fixes. Also invert some return logic so that NS_OK is the normal,
least indented, final return.
2000-09-19 04:22:41 +04:00
|
|
|
* within its current directory. If the newParentDir is
|
2002-05-03 10:01:29 +04:00
|
|
|
* not empty and does not name a directory, an error will
|
2002-06-11 23:26:04 +04:00
|
|
|
* be returned (NS_ERROR_FILE_DESTINATION_NOT_DIR). For
|
|
|
|
* the |moveToNative| method, the newName must be in the
|
|
|
|
* native filesystem charset.
|
1999-10-23 08:51:35 +04:00
|
|
|
*
|
|
|
|
* @param newName
|
Fixes to use atomic rename(2) if possible in nsLocalFile::MoveTo (33098, r=?),
plus a bunch of other fixes and cleanups:
- Fix comment misstatements of fact in nsIFile.idl, improve style slightly.
- Fix typo in comment in nsILocalFile.idl.
- Avoid gratuitous nsCString and nsXPIDLCString copy-constructions, which
entail malloc'ing, in nsLocalFileUnix.cpp's CopyTo and GetParent methods.
But do use nsXPIDLCString instead of raw nsMemory::Alloc/Free.
- Get rid of unnecessary mLL_II2L and mLL_L2II macros, use "prlong.h" API only.
Also use the LL_* macros consistently in case a Unix lacking long long type
support wants to use this code.
* BTW, the "Date" methods should be renamed to use "Time" instead -- after all
PRTime is the type, and traditionally "time" refers to the time-number, a
scalar independent of one's position on the surface of the earth, while
"date" refers to a struct full of locale-specific information derived from
time and some "environment" variables such as DST. Can we rename these
nsIFile methods before Mozilla 0.9 / Netscape 6?
- Use CHECK_mPath consistently and first, before any assertions relating to
arguments (which logically come after the 'this' parameter CHECK_mPath is
making assertions about).
- Use nsCOMPtr for singly-inheriting implementations of XPCOM interfaces, to
avoid scary-when-scaled 0-refcnt instances from being handled (these all
got a ref via QI or equivalent soon enough, but you never know). This also
removed some naked deletes.
- Canonize all paths copied into mPath to lack trailing slashes, so we don't
need to strip trailing slashes elsewhere, in higher-frequency methods (you
set path less often than you get it or a substring of it).
- ssize_t for strlen return values.
- Since shaver used a function pointer to consolidate creat/mkdir logic, but
didn't fold the necessary close of the new fd returned by non-failing creat
into the pointed-at function, I did that.
- AppendRelativePath forbids .. as a component (bounded by / or beginning or
end of string on either side), not just in the middle of fragment (so that
foo..bar is not an illegal relative pathname -- it should not be). BTW,
what the heck is the difference between NS_ERROR_FILE_UNRECOGNIZED_PATH and
...INVALID_PATH?
- SetLeafName was overallocating the new pathname buffer by failing to subtract
the old leafname's length.
- CopyTo was failing to return an NSRESULT_FOR_ERRNO(), it just called that
macro on a line by itself -- eek! It also contained redundant if (newFD
== nsnull) {...} cleanup code, it did a useless PR_GetFileInfo call, and it
leaked FDs on read or write error.
- Implemented CopyToFollowingLinks as a forwarded call to CopyTo, Unix does
not support "copying" a symlink via normal file i/o. Should we instead
lstat in CopyTo and if a link is the source of the copy, do readlink and
then symlink?
- Fixed the readlink method (GetTarget) to null-terminate the link string in
the out parameter (readlink does not do that for you).
- Lots of little nsnull vs. NULL vs. 0, == and != applied to boolean or null
literals, white-space, indentation, bracing, comment, and sloppy code order
(e.g., declaring an initialized variable that's not used till after early
returns) fixes. Also invert some return logic so that NS_OK is the normal,
least indented, final return.
2000-09-19 04:22:41 +04:00
|
|
|
* This param allows you to specify a new name for
|
2002-05-03 10:01:29 +04:00
|
|
|
* the file to be moved. This param may be empty, in
|
Fixes to use atomic rename(2) if possible in nsLocalFile::MoveTo (33098, r=?),
plus a bunch of other fixes and cleanups:
- Fix comment misstatements of fact in nsIFile.idl, improve style slightly.
- Fix typo in comment in nsILocalFile.idl.
- Avoid gratuitous nsCString and nsXPIDLCString copy-constructions, which
entail malloc'ing, in nsLocalFileUnix.cpp's CopyTo and GetParent methods.
But do use nsXPIDLCString instead of raw nsMemory::Alloc/Free.
- Get rid of unnecessary mLL_II2L and mLL_L2II macros, use "prlong.h" API only.
Also use the LL_* macros consistently in case a Unix lacking long long type
support wants to use this code.
* BTW, the "Date" methods should be renamed to use "Time" instead -- after all
PRTime is the type, and traditionally "time" refers to the time-number, a
scalar independent of one's position on the surface of the earth, while
"date" refers to a struct full of locale-specific information derived from
time and some "environment" variables such as DST. Can we rename these
nsIFile methods before Mozilla 0.9 / Netscape 6?
- Use CHECK_mPath consistently and first, before any assertions relating to
arguments (which logically come after the 'this' parameter CHECK_mPath is
making assertions about).
- Use nsCOMPtr for singly-inheriting implementations of XPCOM interfaces, to
avoid scary-when-scaled 0-refcnt instances from being handled (these all
got a ref via QI or equivalent soon enough, but you never know). This also
removed some naked deletes.
- Canonize all paths copied into mPath to lack trailing slashes, so we don't
need to strip trailing slashes elsewhere, in higher-frequency methods (you
set path less often than you get it or a substring of it).
- ssize_t for strlen return values.
- Since shaver used a function pointer to consolidate creat/mkdir logic, but
didn't fold the necessary close of the new fd returned by non-failing creat
into the pointed-at function, I did that.
- AppendRelativePath forbids .. as a component (bounded by / or beginning or
end of string on either side), not just in the middle of fragment (so that
foo..bar is not an illegal relative pathname -- it should not be). BTW,
what the heck is the difference between NS_ERROR_FILE_UNRECOGNIZED_PATH and
...INVALID_PATH?
- SetLeafName was overallocating the new pathname buffer by failing to subtract
the old leafname's length.
- CopyTo was failing to return an NSRESULT_FOR_ERRNO(), it just called that
macro on a line by itself -- eek! It also contained redundant if (newFD
== nsnull) {...} cleanup code, it did a useless PR_GetFileInfo call, and it
leaked FDs on read or write error.
- Implemented CopyToFollowingLinks as a forwarded call to CopyTo, Unix does
not support "copying" a symlink via normal file i/o. Should we instead
lstat in CopyTo and if a link is the source of the copy, do readlink and
then symlink?
- Fixed the readlink method (GetTarget) to null-terminate the link string in
the out parameter (readlink does not do that for you).
- Lots of little nsnull vs. NULL vs. 0, == and != applied to boolean or null
literals, white-space, indentation, bracing, comment, and sloppy code order
(e.g., declaring an initialized variable that's not used till after early
returns) fixes. Also invert some return logic so that NS_OK is the normal,
least indented, final return.
2000-09-19 04:22:41 +04:00
|
|
|
* which case the current leaf name will be used.
|
1999-12-02 04:19:10 +03:00
|
|
|
*/
|
2002-05-08 03:07:19 +04:00
|
|
|
void moveTo(in nsIFile newParentDir, in AString newName);
|
2002-04-27 09:33:09 +04:00
|
|
|
[noscript] void moveToNative(in nsIFile newParentDir, in ACString newName);
|
1999-10-23 08:51:35 +04:00
|
|
|
|
2020-11-10 18:56:47 +03:00
|
|
|
/**
|
|
|
|
* moveToFollowingLinks[Native]
|
|
|
|
*
|
|
|
|
* This function is identical to moveTo with the exception that,
|
|
|
|
* as the name implies, it follows symbolic links. The XP_UNIX
|
|
|
|
* implementation always follows symbolic links when moving. For
|
|
|
|
* the |MoveToFollowingLinks| method, the newName ust be in the native
|
|
|
|
* filesystem charset.
|
|
|
|
*/
|
|
|
|
void moveToFollowingLinks(in nsIFile newParentDir, in AString newName);
|
|
|
|
[noscript] void moveToFollowingLinksNative(in nsIFile newParentDir, in ACString newName);
|
|
|
|
|
2014-01-06 12:51:39 +04:00
|
|
|
/**
|
|
|
|
* renameTo
|
|
|
|
*
|
|
|
|
* This method is identical to moveTo except that if this file or directory
|
|
|
|
* is moved to a a different volume, it fails and returns an error
|
|
|
|
* (NS_ERROR_FILE_ACCESS_DENIED).
|
|
|
|
* This object will still point to the old location after renaming.
|
|
|
|
*/
|
|
|
|
void renameTo(in nsIFile newParentDir, in AString newName);
|
2015-05-16 11:07:10 +03:00
|
|
|
[noscript] void renameToNative(in nsIFile newParentDir, in ACString newName);
|
2014-01-06 12:51:39 +04:00
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
|
|
|
* This will try to delete this file. The 'recursive' flag
|
2012-10-25 20:32:24 +04:00
|
|
|
* must be PR_TRUE to delete directories which are not empty.
|
1999-09-02 03:51:11 +04:00
|
|
|
*
|
|
|
|
* This will not resolve any symlinks.
|
|
|
|
*/
|
2001-07-24 22:38:25 +04:00
|
|
|
void remove(in boolean recursive);
|
1999-08-21 11:38:26 +04:00
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
|
|
|
* Attributes of nsIFile.
|
|
|
|
*/
|
2000-05-15 10:41:00 +04:00
|
|
|
|
1999-12-03 00:45:50 +03:00
|
|
|
attribute unsigned long permissions;
|
|
|
|
attribute unsigned long permissionsOfLink;
|
2000-05-15 10:41:00 +04:00
|
|
|
|
2000-05-09 23:11:14 +04:00
|
|
|
/**
|
2000-05-21 09:42:57 +04:00
|
|
|
* File Times are to be in milliseconds from
|
2000-05-15 10:41:00 +04:00
|
|
|
* midnight (00:00:00), January 1, 1970 Greenwich Mean
|
2000-05-09 23:11:14 +04:00
|
|
|
* Time (GMT).
|
|
|
|
*/
|
2012-08-30 11:10:35 +04:00
|
|
|
attribute PRTime lastModifiedTime;
|
|
|
|
attribute PRTime lastModifiedTimeOfLink;
|
2000-05-15 10:41:00 +04:00
|
|
|
|
2020-12-03 07:10:47 +03:00
|
|
|
/**
|
|
|
|
* The creation time of file in milliseconds from midnight, January 1, 1970
|
|
|
|
* GMT, if available.
|
|
|
|
*
|
|
|
|
* This attribute is only implemented on Windows and macOS. Accessing this
|
|
|
|
* on another platform will this will throw NS_ERROR_NOT_IMPLEMENTED.
|
|
|
|
*/
|
|
|
|
readonly attribute PRTime creationTime;
|
|
|
|
readonly attribute PRTime creationTimeOfLink;
|
|
|
|
|
2000-02-05 02:06:56 +03:00
|
|
|
/**
|
2002-05-03 10:01:29 +04:00
|
|
|
* WARNING! On the Mac, getting/setting the file size with nsIFile
|
|
|
|
* only deals with the size of the data fork. If you need to
|
|
|
|
* know the size of the combined data and resource forks use the
|
|
|
|
* GetFileSizeWithResFork() method defined on nsILocalFileMac.
|
2000-02-05 02:06:56 +03:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
attribute int64_t fileSize;
|
|
|
|
readonly attribute int64_t fileSizeOfLink;
|
2000-05-15 10:41:00 +04:00
|
|
|
|
1999-11-29 17:55:03 +03:00
|
|
|
/**
|
1999-12-02 04:19:10 +03:00
|
|
|
* target & path
|
|
|
|
*
|
2002-05-03 10:01:29 +04:00
|
|
|
* Accessor to the string path. The native version of these
|
|
|
|
* strings are not guaranteed to be a usable path to pass to
|
|
|
|
* NSPR or the C stdlib. There are problems that affect
|
|
|
|
* platforms on which a path does not fully specify a file
|
2006-11-16 12:10:09 +03:00
|
|
|
* because two volumes can have the same name (e.g., mac).
|
2002-05-03 10:01:29 +04:00
|
|
|
* This is solved by holding "private", native data in the
|
|
|
|
* nsIFile implementation. This native data is lost when
|
|
|
|
* you convert to a string.
|
1999-12-02 04:19:10 +03:00
|
|
|
*
|
2002-05-03 10:01:29 +04:00
|
|
|
* DO NOT PASS TO USE WITH NSPR OR STDLIB!
|
1999-12-02 04:19:10 +03:00
|
|
|
*
|
2002-05-03 10:01:29 +04:00
|
|
|
* target
|
1999-12-02 04:19:10 +03:00
|
|
|
* Find out what the symlink points at. Will give error
|
|
|
|
* (NS_ERROR_FILE_INVALID_PATH) if not a symlink.
|
|
|
|
*
|
2002-05-03 10:01:29 +04:00
|
|
|
* path
|
1999-12-02 04:19:10 +03:00
|
|
|
* Find out what the nsIFile points at.
|
2002-06-11 23:26:04 +04:00
|
|
|
*
|
|
|
|
* Note that the ACString attributes are returned in the
|
|
|
|
* native filesystem charset.
|
|
|
|
*
|
1999-11-29 17:55:03 +03:00
|
|
|
*/
|
2002-05-08 03:07:19 +04:00
|
|
|
readonly attribute AString target;
|
2017-01-31 01:17:34 +03:00
|
|
|
[noscript] readonly attribute ACString nativeTarget;
|
2002-05-08 03:07:19 +04:00
|
|
|
readonly attribute AString path;
|
2017-12-30 17:32:27 +03:00
|
|
|
[notxpcom,nostdcall,must_use] PathString nativePath();
|
2017-12-27 21:03:35 +03:00
|
|
|
%{C++
|
2018-01-11 16:38:33 +03:00
|
|
|
#ifndef XP_WIN
|
2017-12-27 21:03:35 +03:00
|
|
|
nsresult GetNativePath(nsACString& aPath);
|
2018-01-11 16:38:33 +03:00
|
|
|
#endif
|
2017-12-30 17:32:27 +03:00
|
|
|
/*
|
|
|
|
* Returns a human-readable path string.
|
|
|
|
*/
|
|
|
|
nsCString HumanReadablePath();
|
2017-12-27 21:03:35 +03:00
|
|
|
%}
|
2000-05-15 10:41:00 +04:00
|
|
|
|
1999-12-03 00:45:50 +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.
|
|
|
|
*/
|
2000-05-15 10:41:00 +04:00
|
|
|
boolean isSpecial();
|
|
|
|
|
2002-05-03 10:01:29 +04:00
|
|
|
/**
|
2000-06-24 05:50:53 +04:00
|
|
|
* createUnique
|
|
|
|
*
|
|
|
|
* 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 this file already exists, we try
|
|
|
|
* variations on the leaf name "suggestedName" until we find
|
|
|
|
* one that did not already exist.
|
|
|
|
*
|
|
|
|
* If the search for nonexistent files takes too long
|
|
|
|
* (thousands of the variants already exist), we give up and
|
|
|
|
* return NS_ERROR_FILE_TOO_BIG.
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
* The unix style octal permissions. This may
|
|
|
|
* be ignored on systems that do not need to do
|
|
|
|
* permissions.
|
2000-06-21 10:32:45 +04:00
|
|
|
*/
|
2016-08-18 06:30:12 +03:00
|
|
|
[must_use]
|
2001-12-08 02:06:51 +03:00
|
|
|
void createUnique(in unsigned long type, in unsigned long permissions);
|
2000-06-21 10:32:45 +04:00
|
|
|
|
1999-12-22 04:56:45 +03:00
|
|
|
/**
|
|
|
|
* clone()
|
|
|
|
*
|
|
|
|
* This function will allocate and initialize a nsIFile object to the
|
|
|
|
* exact location of the |this| nsIFile.
|
2000-05-15 10:41:00 +04:00
|
|
|
*
|
1999-12-22 04:56:45 +03:00
|
|
|
* @param file
|
|
|
|
* A nsIFile which this object will be initialize
|
|
|
|
* with.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
nsIFile clone();
|
|
|
|
|
1999-09-02 03:51:11 +04:00
|
|
|
/**
|
|
|
|
* Will determine if the inFile equals this.
|
|
|
|
*/
|
1999-12-03 00:45:50 +03:00
|
|
|
boolean equals(in nsIFile inFile);
|
2000-05-15 10:41:00 +04:00
|
|
|
|
1999-10-23 08:51:35 +04:00
|
|
|
/**
|
2014-05-08 00:03:41 +04:00
|
|
|
* Will determine if inFile is a descendant of this file.
|
|
|
|
* This routine looks in subdirectories too.
|
1999-10-23 08:51:35 +04:00
|
|
|
*/
|
2014-05-08 00:03:41 +04:00
|
|
|
boolean contains(in nsIFile inFile);
|
1999-12-03 00:45:50 +03:00
|
|
|
|
1999-12-03 03:39:31 +03:00
|
|
|
/**
|
2002-05-03 10:01:29 +04:00
|
|
|
* Parent will be null when this is at the top of the volume.
|
1999-12-03 03:39:31 +03:00
|
|
|
*/
|
|
|
|
readonly attribute nsIFile parent;
|
2019-05-23 01:37:14 +03:00
|
|
|
|
1999-12-03 00:45:50 +03:00
|
|
|
/**
|
2002-05-03 10:01:29 +04:00
|
|
|
* Returns an enumeration of the elements in a directory. Each
|
|
|
|
* element in the enumeration is an nsIFile.
|
1999-12-03 00:45:50 +03:00
|
|
|
*
|
2013-05-16 16:26:55 +04:00
|
|
|
* @throws NS_ERROR_FILE_NOT_DIRECTORY if the current nsIFile does
|
1999-12-03 00:45:50 +03:00
|
|
|
* not specify a directory.
|
2000-05-15 10:41:00 +04:00
|
|
|
*/
|
2018-05-18 01:06:48 +03:00
|
|
|
[binaryname(DirectoryEntriesImpl)]
|
|
|
|
readonly attribute nsIDirectoryEnumerator directoryEntries;
|
|
|
|
|
|
|
|
%{C++
|
|
|
|
nsresult GetDirectoryEntries(nsIDirectoryEnumerator** aOut)
|
|
|
|
{
|
|
|
|
return GetDirectoryEntriesImpl(aOut);
|
|
|
|
};
|
|
|
|
%}
|
2012-04-04 15:04:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* initWith[Native]Path
|
|
|
|
*
|
2012-06-06 06:08:30 +04:00
|
|
|
* This function will initialize the nsIFile object. Any
|
2012-04-04 15:04:37 +04:00
|
|
|
* internal state information will be reset.
|
|
|
|
*
|
|
|
|
* @param filePath
|
|
|
|
* A string which specifies a full file path to a
|
|
|
|
* location. Relative paths will be treated as an
|
|
|
|
* error (NS_ERROR_FILE_UNRECOGNIZED_PATH). For
|
|
|
|
* initWithNativePath, the filePath must be in the native
|
|
|
|
* filesystem charset.
|
|
|
|
*/
|
|
|
|
void initWithPath(in AString filePath);
|
|
|
|
[noscript] void initWithNativePath(in ACString filePath);
|
2019-05-23 01:37:14 +03:00
|
|
|
|
2012-04-04 15:04:37 +04:00
|
|
|
/**
|
|
|
|
* initWithFile
|
|
|
|
*
|
|
|
|
* Initialize this object with another file
|
|
|
|
*
|
|
|
|
* @param aFile
|
|
|
|
* the file this becomes equivalent to
|
|
|
|
*/
|
|
|
|
void initWithFile(in nsIFile aFile);
|
2019-05-23 01:37:14 +03:00
|
|
|
|
2012-09-25 04:50:30 +04:00
|
|
|
/**
|
|
|
|
* Flag for openNSPRFileDesc(), to hint to the OS that the file will be
|
|
|
|
* read sequentially with agressive readahead.
|
|
|
|
*/
|
2012-04-04 15:04:37 +04:00
|
|
|
const unsigned long OS_READAHEAD = 0x40000000;
|
2019-05-23 01:37:14 +03:00
|
|
|
|
2012-09-25 04:50:30 +04:00
|
|
|
/**
|
|
|
|
* Flag for openNSPRFileDesc(). Deprecated and unreliable!
|
|
|
|
* Instead use NS_OpenAnonymousTemporaryFile() to create a temporary
|
|
|
|
* file which will be deleted upon close!
|
|
|
|
*/
|
2012-04-04 15:04:37 +04:00
|
|
|
const unsigned long DELETE_ON_CLOSE = 0x80000000;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the result of PR_Open on the file. The caller is
|
2016-08-18 08:27:16 +03:00
|
|
|
* responsible for calling PR_Close on the result. On success, the
|
|
|
|
* returned PRFileDescr must be non-null.
|
2012-04-04 15:04:37 +04:00
|
|
|
*
|
|
|
|
* @param flags the PR_Open flags from prio.h, plus optionally
|
|
|
|
* OS_READAHEAD or DELETE_ON_CLOSE. OS_READAHEAD is a hint to the
|
|
|
|
* OS that the file will be read sequentially with agressive
|
2012-09-25 04:50:30 +04:00
|
|
|
* readahead. DELETE_ON_CLOSE is unreliable on Windows and is deprecated.
|
|
|
|
* Instead use NS_OpenAnonymousTemporaryFile() to create a temporary
|
|
|
|
* file which will be deleted upon close.
|
2012-04-04 15:04:37 +04:00
|
|
|
*/
|
2016-08-18 08:27:16 +03:00
|
|
|
[noscript, must_use] PRFileDescStar openNSPRFileDesc(in long flags,
|
|
|
|
in long mode);
|
2012-04-04 15:04:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the result of fopen on the file. The caller is
|
2016-08-18 08:27:16 +03:00
|
|
|
* responsible for calling fclose on the result. On success, the
|
|
|
|
* returned FILE pointer must be non-null.
|
2012-04-04 15:04:37 +04:00
|
|
|
*/
|
2016-08-18 08:27:16 +03:00
|
|
|
[noscript, must_use] FILE openANSIFileDesc(in string mode);
|
2012-04-04 15:04:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the result of PR_LoadLibrary on the file. The caller is
|
|
|
|
* responsible for calling PR_UnloadLibrary on the result.
|
|
|
|
*/
|
2016-08-18 09:43:28 +03:00
|
|
|
[noscript, must_use] PRLibraryStar load();
|
2012-04-04 15:04:37 +04:00
|
|
|
|
|
|
|
// number of bytes available on disk to non-superuser
|
2016-08-18 09:43:28 +03:00
|
|
|
[must_use] readonly attribute int64_t diskSpaceAvailable;
|
2012-04-04 15:04:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* appendRelative[Native]Path
|
|
|
|
*
|
2012-06-06 06:08:30 +04:00
|
|
|
* Append a relative path to the current path of the nsIFile object.
|
2012-04-04 15:04:37 +04:00
|
|
|
*
|
|
|
|
* @param relativeFilePath
|
|
|
|
* relativeFilePath is a native relative path. For security reasons,
|
|
|
|
* this cannot contain .. or cannot start with a directory separator.
|
|
|
|
* For the |appendRelativeNativePath| method, the relativeFilePath
|
|
|
|
* must be in the native filesystem charset.
|
|
|
|
*/
|
|
|
|
void appendRelativePath(in AString relativeFilePath);
|
|
|
|
[noscript] void appendRelativeNativePath(in ACString relativeFilePath);
|
2019-05-23 01:37:14 +03:00
|
|
|
|
2012-04-04 15:04:37 +04:00
|
|
|
/**
|
|
|
|
* Accessor to a null terminated string which will specify
|
|
|
|
* the file in a persistent manner for disk storage.
|
|
|
|
*
|
|
|
|
* The character set of this attribute is undefined. DO NOT TRY TO
|
|
|
|
* INTERPRET IT AS HUMAN READABLE TEXT!
|
|
|
|
*/
|
2016-08-18 09:43:28 +03:00
|
|
|
[must_use] attribute ACString persistentDescriptor;
|
2012-04-04 15:04:37 +04:00
|
|
|
|
2016-08-18 09:43:28 +03:00
|
|
|
/**
|
2012-04-04 15:04:37 +04:00
|
|
|
* reveal
|
|
|
|
*
|
|
|
|
* Ask the operating system to open the folder which contains
|
2016-08-18 09:43:28 +03:00
|
|
|
* this file or folder. This routine only works on platforms which
|
|
|
|
* support the ability to open a folder and is run async on Windows.
|
|
|
|
* This routine must be called on the main.
|
2012-04-04 15:04:37 +04:00
|
|
|
*/
|
2016-08-18 09:43:28 +03:00
|
|
|
[must_use] void reveal();
|
|
|
|
|
|
|
|
/**
|
2012-04-04 15:04:37 +04:00
|
|
|
* launch
|
|
|
|
*
|
2016-08-18 09:43:28 +03:00
|
|
|
* Ask the operating system to attempt to open the file.
|
2012-04-04 15:04:37 +04:00
|
|
|
* this really just simulates "double clicking" the file on your platform.
|
|
|
|
* This routine only works on platforms which support this functionality
|
2016-08-18 09:43:28 +03:00
|
|
|
* and is run async on Windows. This routine must be called on the
|
|
|
|
* main thread.
|
2012-04-04 15:04:37 +04:00
|
|
|
*/
|
2016-08-18 09:43:28 +03:00
|
|
|
[must_use] void launch();
|
|
|
|
|
2012-04-04 15:04:37 +04:00
|
|
|
/**
|
|
|
|
* getRelativeDescriptor
|
|
|
|
*
|
|
|
|
* Returns a relative file path in an opaque, XP format. It is therefore
|
|
|
|
* not a native path.
|
|
|
|
*
|
|
|
|
* The character set of the string returned from this function is
|
|
|
|
* undefined. DO NOT TRY TO INTERPRET IT AS HUMAN READABLE TEXT!
|
|
|
|
*
|
|
|
|
* @param fromFile
|
|
|
|
* the file from which the descriptor is relative.
|
2015-06-17 23:17:20 +03:00
|
|
|
* Throws if fromFile is null.
|
2012-04-04 15:04:37 +04:00
|
|
|
*/
|
2016-08-18 09:43:28 +03:00
|
|
|
[must_use] ACString getRelativeDescriptor(in nsIFile fromFile);
|
2012-04-04 15:04:37 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* setRelativeDescriptor
|
|
|
|
*
|
|
|
|
* Initializes the file to the location relative to fromFile using
|
|
|
|
* a string returned by getRelativeDescriptor.
|
|
|
|
*
|
|
|
|
* @param fromFile
|
|
|
|
* the file to which the descriptor is relative
|
|
|
|
* @param relative
|
|
|
|
* the relative descriptor obtained from getRelativeDescriptor
|
|
|
|
*/
|
2016-08-18 09:43:28 +03:00
|
|
|
[must_use]
|
|
|
|
void setRelativeDescriptor(in nsIFile fromFile, in ACString relativeDesc);
|
2015-06-17 23:17:20 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* getRelativePath
|
|
|
|
*
|
|
|
|
* Returns a relative file from 'fromFile' to this file as a UTF-8 string.
|
|
|
|
* Going up the directory tree is represented via "../". '/' is used as
|
|
|
|
* the path segment separator. This is not a native path, since it's UTF-8
|
|
|
|
* encoded.
|
|
|
|
*
|
|
|
|
* @param fromFile
|
|
|
|
* the file from which the path is relative.
|
|
|
|
* Throws if fromFile is null.
|
|
|
|
*/
|
2016-08-18 09:43:28 +03:00
|
|
|
[must_use] AUTF8String getRelativePath(in nsIFile fromFile);
|
2015-06-17 23:17:20 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* setRelativePath
|
|
|
|
*
|
|
|
|
* Initializes the file to the location relative to fromFile using
|
|
|
|
* a string returned by getRelativePath.
|
|
|
|
*
|
|
|
|
* @param fromFile
|
|
|
|
* the file from which the path is relative
|
|
|
|
* @param relative
|
|
|
|
* the relative path obtained from getRelativePath
|
|
|
|
*/
|
2016-08-18 09:43:28 +03:00
|
|
|
[must_use]
|
2015-06-17 23:17:20 +03:00
|
|
|
void setRelativePath(in nsIFile fromFile, in AUTF8String relativeDesc);
|
1999-08-21 11:38:26 +04:00
|
|
|
};
|
1999-09-09 00:12:35 +04:00
|
|
|
|
|
|
|
%{C++
|
2005-04-06 07:35:24 +04:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
|
|
|
#include "nsDirectoryServiceUtils.h"
|
2019-04-02 01:05:37 +03:00
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& aOut, const nsIFile& aFile) {
|
|
|
|
nsIFile* file = const_cast<nsIFile*>(&aFile);
|
|
|
|
nsAutoString path;
|
|
|
|
file->GetPath(path);
|
|
|
|
return aOut << "nsIFile { " << path << " }";
|
|
|
|
}
|
2002-03-20 03:34:17 +03:00
|
|
|
#endif
|
1999-11-01 07:44:56 +03:00
|
|
|
%}
|