1999-05-26 05:38:36 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
|
1999-06-10 00:49:39 +04:00
|
|
|
%{C++
|
|
|
|
#include "nsFileSpec.h" // for factory method
|
|
|
|
%}
|
|
|
|
|
1999-05-26 05:38:36 +04:00
|
|
|
interface nsIFileURL;
|
|
|
|
interface nsIFilePath;
|
1999-06-15 02:05:41 +04:00
|
|
|
interface nsIOutputStream;
|
|
|
|
interface nsIInputStream;
|
1999-05-26 05:38:36 +04:00
|
|
|
|
1999-05-28 02:47:27 +04:00
|
|
|
// Define Progid and CID
|
|
|
|
%{C++
|
|
|
|
// {A5740FA2-146E-11d3-B00D-00C04FC2E79B}
|
|
|
|
#define NS_FILESPEC_CID \
|
|
|
|
{ 0xa5740fa2, 0x146e, 0x11d3, { 0xb0, 0xd, 0x0, 0xc0, 0x4f, 0xc2, 0xe7, 0x9b } }
|
|
|
|
|
|
|
|
#define NS_FILESPEC_PROGID "component://netscape/filespec"
|
|
|
|
#define NS_FILESPEC_CLASSNAME "File Spec"
|
1999-06-15 02:05:41 +04:00
|
|
|
|
1999-05-28 02:47:27 +04:00
|
|
|
%}
|
1999-05-29 05:29:28 +04:00
|
|
|
|
1999-06-22 09:03:30 +04:00
|
|
|
native nsFileSpec(nsFileSpec);
|
|
|
|
[ref] native nsFileSpecRef(nsFileSpec);
|
1999-06-27 00:27:28 +04:00
|
|
|
[ptr] native nsFileSpecPtr(nsFileSpec);
|
1999-06-15 02:05:41 +04:00
|
|
|
|
1999-05-26 05:38:36 +04:00
|
|
|
[scriptable, uuid(d8c0a080-0868-11d3-915f-d9d889d48e3c)]
|
|
|
|
interface nsIFileSpec : nsISupports
|
|
|
|
{
|
|
|
|
void fromFileSpec([const] in nsIFileSpec original);
|
|
|
|
|
|
|
|
attribute string URLString;
|
1999-08-25 09:26:25 +04:00
|
|
|
attribute string unixStyleFilePath;
|
|
|
|
attribute string persistentDescriptorString;
|
|
|
|
attribute string nativePath;
|
1999-05-26 05:38:36 +04:00
|
|
|
|
|
|
|
readonly attribute string NSPRPath;
|
|
|
|
|
|
|
|
void error();
|
|
|
|
|
|
|
|
boolean isValid();
|
|
|
|
boolean failed();
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
attribute string leafName;
|
1999-05-26 05:38:36 +04:00
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
readonly attribute nsIFileSpec parent;
|
|
|
|
readonly attribute nsIInputStream inputStream;
|
|
|
|
readonly attribute nsIOutputStream outputStream;
|
1999-09-04 03:44:59 +04:00
|
|
|
boolean isChildOf(in nsIFileSpec possibleParent);
|
1999-08-25 09:26:25 +04:00
|
|
|
[noscript] readonly attribute nsFileSpec fileSpec;
|
1999-07-31 21:37:29 +04:00
|
|
|
[noscript] void setFromFileSpec([const] in nsFileSpecRef spec);
|
1999-06-15 02:05:41 +04:00
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
attribute string fileContents;
|
1999-05-26 05:38:36 +04:00
|
|
|
|
|
|
|
void makeUnique();
|
|
|
|
void makeUniqueWithSuggestedName(in string suggestedName);
|
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
readonly attribute unsigned long modDate;
|
1999-05-26 05:38:36 +04:00
|
|
|
boolean modDateChanged(in unsigned long oldStamp);
|
|
|
|
|
|
|
|
boolean isDirectory();
|
|
|
|
boolean isFile();
|
|
|
|
boolean exists();
|
1999-08-25 09:26:25 +04:00
|
|
|
boolean isHidden();
|
1999-05-26 05:38:36 +04:00
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
readonly attribute unsigned long fileSize;
|
1999-09-11 00:03:56 +04:00
|
|
|
readonly attribute long long diskSpaceAvailable;
|
1999-05-26 05:38:36 +04:00
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
void appendRelativeUnixPath(in string relativePath);
|
1999-05-26 05:38:36 +04:00
|
|
|
|
|
|
|
void createDir();
|
1999-07-13 23:10:43 +04:00
|
|
|
void touch();
|
1999-07-27 02:09:42 +04:00
|
|
|
|
1999-08-25 09:26:25 +04:00
|
|
|
boolean isSymlink();
|
|
|
|
void resolveSymlink();
|
1999-07-27 02:09:42 +04:00
|
|
|
|
1999-05-26 05:38:36 +04:00
|
|
|
void rename([const] in string newLeafName);
|
|
|
|
void copyToDir([const] in nsIFileSpec newParentDir);
|
|
|
|
void moveToDir([const] in nsIFileSpec newParentDir);
|
|
|
|
void execute([const] in string args);
|
|
|
|
|
|
|
|
void openStreamForReading();
|
|
|
|
void openStreamForWriting();
|
|
|
|
void openStreamForReadingAndWriting();
|
|
|
|
void closeStream();
|
|
|
|
boolean isStreamOpen();
|
|
|
|
|
|
|
|
boolean eof();
|
|
|
|
long read(inout string buffer, in long requestedCount);
|
|
|
|
void readLine(inout string line, in long bufferSize, out boolean wasTruncated);
|
|
|
|
%{C++
|
|
|
|
// Check eof() before each call.
|
|
|
|
// CAUTION: false result only indicates line was truncated
|
|
|
|
// to fit buffer, or an error occurred (OTHER THAN eof).
|
|
|
|
%}
|
|
|
|
long write(in string data, in long requestedCount);
|
|
|
|
void flush();
|
|
|
|
|
|
|
|
void seek(in long offset);
|
|
|
|
long tell();
|
1999-08-25 09:26:25 +04:00
|
|
|
void endLine();
|
1999-05-26 05:38:36 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
1999-06-15 02:05:41 +04:00
|
|
|
// Define Progid and CID
|
|
|
|
%{C++
|
|
|
|
// {a3020981-2018-11d3-915f-a957795b7ebc}
|
|
|
|
#define NS_DIRECTORYITERATOR_CID \
|
|
|
|
{ 0xa3020981, 0x2018, 0x11d3, { 0x91, 0x5f, 0xa9, 0x57, 0x79, 0x5b, 0x7e, 0xbc } }
|
|
|
|
|
|
|
|
#define NS_DIRECTORYITERATOR_PROGID "component://netscape/directoryiterator"
|
|
|
|
#define NS_DIRECTORYITERATOR_CLASSNAME "nsIDirectoryIterator"
|
|
|
|
%}
|
|
|
|
|
1999-05-26 05:38:36 +04:00
|
|
|
[scriptable, uuid(d8c0a083-0868-11d3-915f-d9d889d48e3c)]
|
|
|
|
interface nsIDirectoryIterator : nsISupports
|
|
|
|
{
|
1999-08-25 09:26:25 +04:00
|
|
|
void init(in nsIFileSpec parent, in boolean resolveSymlink);
|
1999-05-26 05:38:36 +04:00
|
|
|
boolean exists();
|
|
|
|
void next();
|
|
|
|
readonly attribute nsIFileSpec currentSpec;
|
|
|
|
};
|
|
|
|
|
|
|
|
%{C++
|
1999-06-15 09:17:59 +04:00
|
|
|
// Factory methods if you link with xpcom
|
1999-06-22 09:03:30 +04:00
|
|
|
NS_COM nsresult NS_NewFileSpecWithSpec(const nsFileSpec& aSrcFileSpec, nsIFileSpec **result);
|
1999-05-26 05:38:36 +04:00
|
|
|
NS_COM nsresult NS_NewFileSpec(nsIFileSpec** result);
|
|
|
|
NS_COM nsresult NS_NewDirectoryIterator(nsIDirectoryIterator** result);
|
1999-06-15 02:05:41 +04:00
|
|
|
|
1999-06-15 09:17:59 +04:00
|
|
|
#define NS_BOOL_ACCESSOR(_method) { PRBool yes; return NS_SUCCEEDED(f->_method(&yes)) && yes; }
|
1999-08-25 09:26:25 +04:00
|
|
|
inline PRBool Exists(nsIFileSpec* f) NS_BOOL_ACCESSOR(Exists)
|
|
|
|
inline PRBool Exists(nsIDirectoryIterator* f) NS_BOOL_ACCESSOR(Exists)
|
|
|
|
inline PRBool IsDirectory(nsIFileSpec* f) NS_BOOL_ACCESSOR(IsDirectory)
|
1999-06-15 09:17:59 +04:00
|
|
|
|
1999-05-26 05:38:36 +04:00
|
|
|
%}
|