Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/**
* An event that is fired when a file system provider is added or removed
*/
readonly
:
<
>
;
/**
* An event that is fired when a registered file system provider changes its capabilities.
*/
readonly
:
<
>
;
/**
* An event that is fired when a file system provider is about to be activated. Listeners
* can join this event with a long running promise to help in the activation process.
*/
readonly
:
<
>
;
/**
* Registers a file system provider for a certain scheme.
*/
registerProvider
(
:
string
,
:
)
:
;
/**
* Returns a file system provider for a certain scheme.
*/
getProvider
(
:
string
)
:
|
undefined
;
/**
* Tries to activate a provider with the given scheme.
*/
activateProvider
(
:
string
)
:
Promise
<
void
>
;
/**
* Checks if this file service can handle the given resource by
* first activating any extension that wants to be activated
* on the provided resource scheme to include extensions that
* contribute file system providers for the given resource.
*/
canHandleResource
(
:
URI
)
:
Promise
<
boolean
>
;
/**
* Checks if the file service has a registered provider for the
* provided resource.
*
* Note: this does NOT account for contributed providers from
* extensions that have not been activated yet. To include those,
* consider to call `await fileService.canHandleResource(resource)`.
*/
hasProvider
(
:
URI
)
:
boolean
;
/**
* Checks if the provider for the provided resource has the provided file system capability.
*/
hasCapability
(
:
URI
,
:
)
:
boolean
;
/**
* List the schemes and capabilities for registered file system providers
*/
listCapabilities
(
)
:
<
{
:
string
;
:
}
>
;
/**
* Allows to listen for file changes. The event will fire for every file within the opened workspace
* (if any) as well as all files that have been watched explicitly using the #watch() API.
*/
readonly
:
<
>
;
/**
* An event that is fired upon successful completion of a certain file operation.
*/
readonly
:
<
>
;
/**
* Resolve the properties of a file/folder identified by the resource. For a folder, children
* information is resolved as well depending on the provided options. Use `stat()` method if
* you do not need children information.
*
* If the optional parameter "resolveTo" is specified in options, the stat service is asked
* to provide a stat object that should contain the full graph of folders up to all of the
* target resources.
*
* If the optional parameter "resolveSingleChildDescendants" is specified in options,
* the stat service is asked to automatically resolve child folders that only
* contain a single element.
*
* If the optional parameter "resolveMetadata" is specified in options,
* the stat will contain metadata information such as size, mtime and etag.
*/
resolve
(
:
URI
,
:
)
:
Promise
<
>
;
resolve
(
:
URI
,
?
:
)
:
Promise
<
>
;
/**
* Same as `resolve()` but supports resolving multiple resources in parallel.
*
* If one of the resolve targets fails to resolve returns a fake `IFileStat` instead of
* making the whole call fail.
*/
resolveAll
(
:
{
:
URI
;
:
}
[
]
)
:
Promise
<
[
]
>
;
resolveAll
(
:
{
:
URI
;
?
:
}
[
]
)
:
Promise
<
[
]
>
;
/**
* Same as `resolve()` but without resolving the children of a folder if the
* resource is pointing to a folder.
*/
stat
(
:
URI
)
:
Promise
<
>
;
/**
* Attempts to resolve the real path of the provided resource. The real path can be
* different from the resource path for example when it is a symlink.
*
* Will return `undefined` if the real path cannot be resolved.
*/
realpath
(
:
URI
)
:
Promise
<
URI
|
undefined
>
;
/**
* Finds out if a file/folder identified by the resource exists.
*/
exists
(
:
URI
)
:
Promise
<
boolean
>
;
/**
* Read the contents of the provided resource unbuffered.
*/
readFile
(
:
URI
,
?
:
,
?
:
)
:
Promise
<
>
;
/**
* Read the contents of the provided resource buffered as stream.
*/
readFileStream
(
:
URI
,
?
:
,
?
:
)
:
Promise
<
>
;
/**
* Updates the content replacing its previous value.
* If `options.append` is true, appends content to the end of the file instead.
*
* Emits a `FileOperation.WRITE` file operation event when successful.
*/
writeFile
(
:
URI
,
:
|
|
,
?
:
)
:
Promise
<
>
;
/**
* Moves the file/folder to a new path identified by the resource.
*
* The optional parameter overwrite can be set to replace an existing file at the location.
*
* Emits a `FileOperation.MOVE` file operation event when successful.
*/
move
(
:
URI
,
:
URI
,
?
:
boolean
)
:
Promise
<
>
;
/**
* Find out if a move operation is possible given the arguments. No changes on disk will
* be performed. Returns an Error if the operation cannot be done.
*/
canMove
(
:
URI
,
:
URI
,
?
:
boolean
)
:
Promise
<
|
true
>
;
/**
* Copies the file/folder to a path identified by the resource. A folder is copied
* recursively.
*
* Emits a `FileOperation.COPY` file operation event when successful.
*/
copy
(
:
URI
,
:
URI
,
?
:
boolean
)
:
Promise
<
>
;
/**
* Find out if a copy operation is possible given the arguments. No changes on disk will
* be performed. Returns an Error if the operation cannot be done.
*/
canCopy
(
:
URI
,
:
URI
,
?
:
boolean
)
:
Promise
<
|
true
>
;
/**
* Clones a file to a path identified by the resource. Folders are not supported.
*
* If the target path exists, it will be overwritten.
*/
cloneFile
(
:
URI
,
:
URI
)
:
Promise
<
void
>
;
/**
* Creates a new file with the given path and optional contents. The returned promise
* will have the stat model object as a result.
*
* The optional parameter content can be used as value to fill into the new file.
*
* Emits a `FileOperation.CREATE` file operation event when successful.
*/
createFile
(
:
URI
,
?
:
|
|
,
?
:
)
:
Promise
<
>
;
/**
* Find out if a file create operation is possible given the arguments. No changes on disk will
* be performed. Returns an Error if the operation cannot be done.
*/
canCreateFile
(
:
URI
,
?
:
)
:
Promise
<
|
true
>
;
/**
* Creates a new folder with the given path. The returned promise
* will have the stat model object as a result.
*
* Emits a `FileOperation.CREATE` file operation event when successful.
*/
createFolder
(
:
URI
)
:
Promise
<
>
;
/**
* Deletes the provided file. The optional useTrash parameter allows to
* move the file to trash. The optional recursive parameter allows to delete
* non-empty folders recursively.
*
* Emits a `FileOperation.DELETE` file operation event when successful.
*/
del
(
:
URI
,
?
:
<
>
)
:
Promise
<
void
>
;
/**
* Find out if a delete operation is possible given the arguments. No changes on disk will
* be performed. Returns an Error if the operation cannot be done.
*/
canDelete
(
:
URI
,
?
:
<
>
)
:
Promise
<
|
true
>
;
/**
* An event that signals an error when watching for file changes.
*/
readonly
:
<
>
;
/**
* Allows to start a watcher that reports file/folder change events on the provided resource.
*
* The watcher runs correlated and thus, file events will be reported on the returned
* `IFileSystemWatcher` and not on the generic `IFileService.onDidFilesChange` event.
*
* Note: only non-recursive file watching supports event correlation for now.
*/
createWatcher
(
:
URI
,
:
&
{
:
false
}
)
:
;
/**
* Allows to start a watcher that reports file/folder change events on the provided resource.
*
* The watcher runs uncorrelated and thus will report all events from `IFileService.onDidFilesChange`.
* This means, most listeners in the application will receive your events. It is encouraged to
* use correlated watchers (via `IWatchOptionsWithCorrelation`) to limit events to your listener.
*/
watch
(
:
URI
,
?
:
)
:
;
/**
* Frees up any resources occupied by this service.
*/
dispose
(
)
:
void
;
}
export
interface
IFileOverwriteOptions
{
/**
* Set to `true` to overwrite a file if it exists. Will
* throw an error otherwise if the file does exist.
*/
readonly
:
boolean
;
}
export
interface
IFileUnlockOptions
{
/**
* Set to `true` to try to remove any write locks the file might
* have. A file that is write locked will throw an error for any
* attempt to write to unless `unlock: true` is provided.
*/
readonly
:
boolean
;
}
export
interface
IFileAtomicReadOptions
{
/**
* The optional `atomic` flag can be used to make sure
* the `readFile` method is not running in parallel with
* any `write` operations in the same process.
*
* Typically you should not need to use this flag but if
* for example you are quickly reading a file right after
* a file event occurred and the file changes a lot, there
* is a chance that a read returns an empty or partial file
* because a pending write has not finished yet.
*
* Note: this does not prevent the file from being written
* to from a different process. If you need such atomic
* operations, you better use a real database as storage.
*/
readonly
:
boolean
;
}
export
interface
IFileAtomicOptions
{
/**
* The postfix is used to create a temporary file based
* on the original resource. The resulting temporary
* file will be in the same folder as the resource and
* have `postfix` appended to the resource name.
*
* Example: given a file resource `file:///some/path/foo.txt`
* and a postfix `.vsctmp`, the temporary file will be
* created as `file:///some/path/foo.txt.vsctmp`.
*/
readonly
:
string
;
}
export
interface
IFileAtomicWriteOptions
{
/**
* The optional `atomic` flag can be used to make sure
* the `writeFile` method updates the target file atomically
* by first writing to a temporary file in the same folder
* and then renaming it over the target.
*/
readonly
:
|
false
;
}
export
interface
IFileAtomicDeleteOptions
{
/**
* The optional `atomic` flag can be used to make sure
* the `delete` method deletes the target atomically by
* first renaming it to a temporary resource in the same
* folder and then deleting it.
*/
readonly
:
|
false
;
}
export
interface
IFileReadLimits
{
/**
* If the file exceeds the given size, an error of kind
* `FILE_TOO_LARGE` will be thrown.
*/
?
:
number
;
}
export
interface
IFileReadStreamOptions
{
/**
* Is an integer specifying where to begin reading from in the file. If position is undefined,
* data will be read from the current file position.
*/
readonly
?
:
number
;
/**
* Is an integer specifying how many bytes to read from the file. By default, all bytes
* will be read.
*/
readonly
?
:
number
;
/**
* If provided, the size of the file will be checked against the limits
* and an error will be thrown if any limit is exceeded.
*/
readonly
?
:
;
}
export
interface
IFileWriteOptions
extends
IFileOverwriteOptions
,
,
{
/**
* Set to `true` to create a file when it does not exist. Will
* throw an error otherwise if the file does not exist.
*/
readonly
:
boolean
;
/**
* Set to `true` to append content to the end of the file. Implies `create: true`,
* and set only when the corresponding `FileAppend` capability is defined.
*/
readonly
?
:
boolean
;
}
export
type
IFileOpenOptions
=
|
;
export
function
isFileOpenForWriteOptions
(
:
)
:
is
{
return
.
===
true
;
}
export
interface
IFileOpenForReadOptions
{
/**
* A hint that the file should be opened for reading only.
*/
readonly
:
false
;
}
export
interface
IFileOpenForWriteOptions
extends
IFileUnlockOptions
{
/**
* A hint that the file should be opened for reading and writing.
*/
readonly
:
true
;
/**
* Open the file in append mode. This will write data to the
* end of the file.
*/
readonly
?
:
boolean
;
}
export
interface
IFileDeleteOptions
{
/**
* Set to `true` to recursively delete any children of the file. This
* only applies to folders and can lead to an error unless provided
* if the folder is not empty.
*/
readonly
:
boolean
;
/**
* Set to `true` to attempt to move the file to trash
* instead of deleting it permanently from disk.
*
* This option maybe not be supported on all providers.
*/
readonly
:
boolean
;
/**
* The optional `atomic` flag can be used to make sure
* the `delete` method deletes the target atomically by
* first renaming it to a temporary resource in the same
* folder and then deleting it.
*
* This option maybe not be supported on all providers.
*/
readonly
:
|
false
;
}
export
enum
{
/**
* File is unknown (neither file, directory nor symbolic link).
*/
=
0
,
/**
* File is a normal file.
*/
=
1
,
/**
* File is a directory.
*/
=
2
,
/**
* File is a symbolic link.
*
* Note: even when the file is a symbolic link, you can test for
* `FileType.File` and `FileType.Directory` to know the type of
* the target the link points to.
*/
=
64
}
export
enum
{
/**
* File is readonly. Components like editors should not
* offer to edit the contents.
*/
=
1
,
/**
* File is locked. Components like editors should offer
* to edit the contents and ask the user upon saving to
* remove the lock.
*/
=
2
,
/**
* File is executable. Relevant for Unix-like systems where
* the executable bit determines if a file can be run.
*/
=
4
}
export
interface
IStat
{
/**
* The file type.
*/
readonly
:
;
/**
* The last modification date represented as millis from unix epoch.
*/
readonly
:
number
;
/**
* The creation date represented as millis from unix epoch.
*/
readonly
:
number
;
/**
* The size of the file in bytes.
*/
readonly
:
number
;
/**
* The file permissions.
*/
readonly
?
:
;
}
export
interface
IWatchOptionsWithoutCorrelation
{
/**
* Set to `true` to watch for changes recursively in a folder
* and all of its children.
*/
:
boolean
;
/**
* A set of glob patterns or paths to exclude from watching.
* Paths can be relative or absolute and when relative are
* resolved against the watched folder. Glob patterns are
* always matched relative to the watched folder.
*/
:
string
[
]
;
/**
* An optional set of glob patterns or paths to include for
* watching. If not provided, all paths are considered for
* events.
* Paths can be relative or absolute and when relative are
* resolved against the watched folder. Glob patterns are
* always matched relative to the watched folder.
*/
?
:
Array
<
string
|
>
;
/**
* If provided, allows to filter the events that the watcher should consider
* for emitting. If not provided, all events are emitted.
*
* For example, to emit added and updated events, set to:
* `FileChangeFilter.ADDED | FileChangeFilter.UPDATED`.
*/
?
:
;
}
export
interface
IWatchOptions
extends
IWatchOptionsWithoutCorrelation
{
/**
* If provided, file change events from the watcher that
* are a result of this watch request will carry the same
* id.
*/
readonly
?
:
number
;
}
export
const
enum
{
UPDATED
=
1
<<
1
,
ADDED
=
1
<<
2
,
DELETED
=
1
<<
3
}
export
interface
IWatchOptionsWithCorrelation
extends
IWatchOptions
{
readonly
:
number
;
}
export
interface
IFileSystemWatcher
extends
IDisposable
{
/**
* An event which fires on file/folder change only for changes
* that correlate to the watch request with matching correlation
* identifier.
*/
// Any other error, check for name match by assuming that the error
// went through the markAsFileSystemProviderError() method
const
=
/^(.+)\(FileSystemError\)$/
.
exec
(
.
)
;
if
(
!
)
{
return
.
;
}
switch
(
[
1
]
)
{
case
.
:
return
.
;
case
.
:
return
.
;
case
.
:
return
.
;
case
.
:
return
.
;
case
.
:
return
.
;
case
.
:
return
.
;
case
.
:
return
.
;
case
.
:
return
.
;
}
return
.
;
}
export
function
toFileOperationResult
(
:
)
:
{
// FileSystemProviderError comes with the result already
if
(
instanceof
FileOperationError
)
{
return
.
;
}
// Otherwise try to find from code
switch
(
toFileSystemProviderErrorCode
(
)
)
{
case
.
:
return
.
FILE_NOT_FOUND
;
case
.
:
return
.
FILE_IS_DIRECTORY
;
case
.
:
return
.
FILE_NOT_DIRECTORY
;
case
.
:
return
.
FILE_WRITE_LOCKED
;
case
.
:
return
.
FILE_PERMISSION_DENIED
;
case
.
:
return
.
FILE_MOVE_CONFLICT
;
case
.
:
return
.
FILE_TOO_LARGE
;
default
:
return
.
FILE_OTHER_ERROR
;
}
}
export
interface
IFileSystemProviderRegistrationEvent
{
readonly
:
boolean
;
readonly
:
string
;
readonly
?
:
;
}
export
interface
IFileSystemProviderCapabilitiesChangeEvent
{
readonly
:
;
readonly
:
string
;
}
export
interface
IFileSystemProviderActivationEvent
{
readonly
:
string
;
join
(
:
Promise
<
void
>
)
:
void
;
}
export
const
enum
{
CREATE
,
DELETE
,
MOVE
,
COPY
,
WRITE
}
export
interface
IFileOperationEvent
{
readonly
:
URI
;
readonly
:
;
isOperation
(
:
.
DELETE
|
.
WRITE
)
:
boolean
;
isOperation
(
:
.
CREATE
|
.
MOVE
|
.
COPY
)
:
this
is
;
}
export
interface
IFileOperationEventWithMetadata
extends
IFileOperationEvent
{
readonly
:
;
}
export
class
FileOperationEvent
implements
IFileOperationEvent
{
constructor
(
:
URI
,
:
.
DELETE
|
.
WRITE
)
;
constructor
(
:
URI
,
:
.
CREATE
|
.
MOVE
|
.
COPY
,
:
)
;
constructor
(
readonly
:
URI
,
readonly
:
,
readonly
?
:
)
{
}
isOperation
(
:
.
DELETE
|
.
WRITE
)
:
boolean
;
isOperation
(
:
.
CREATE
|
.
MOVE
|
.
COPY
)
:
this
is
;
isOperation
(
:
)
:
boolean
{
return
this
.
===
;
}
}
/**
* Possible changes that can occur to a file.
*/
export
const
enum
{
UPDATED
,
ADDED
,
DELETED
}
/**
* Identifies a single change in a file.
*/
export
interface
IFileChange
{
/**
* The type of change that occurred to the file.
*/
:
;
/**
* The unified resource identifier of the file that changed.
*/
readonly
:
URI
;
/**
* If provided when starting the file watcher, the correlation
* identifier will match the original file watching request as
* a way to identify the original component that is interested
* in the change.
*/
readonly
?
:
number
;
}
export
class
FileChangesEvent
{
private
static
readonly
MIXED_CORRELATION
=
null
;
private
readonly
:
number
|
undefined
|
typeof
.
MIXED_CORRELATION
=
undefined
;
constructor
(
:
readonly
[
]
,
private
readonly
:
boolean
)
{
for
(
const
of
)
{
// Split by type
switch
(
.
)
{
case
.
ADDED
:
this
.
.
push
(
.
)
;
break
;
case
.
UPDATED
:
this
.
.
push
(
.
)
;
break
;
case
.
DELETED
:
this
.
.
push
(
.
)
;
break
;
}
// Figure out events correlation
if
(
this
.
!==
.
MIXED_CORRELATION
)
{
if
(
typeof
.
===
'number'
)
{
if
(
this
.
===
undefined
)
{
this
.
=
.
;
// correlation not yet set, just take it
}
else
if
(
this
.
!==
.
)
{
this
.
=
.
MIXED_CORRELATION
;
// correlation mismatch, we have mixed correlation
}
}
else
{
if
(
this
.
!==
undefined
)
{
this
.
=
.
MIXED_CORRELATION
;
// correlation mismatch, we have mixed correlation
}
}
}
}
}
private
readonly
=
new
Lazy
(
(
)
=>
{
const
=
.
forUris<boolean>
(
(
)
=>
this
.
)
;
.
fill
(
this
.
.
map
(
=>
[
,
true
]
)
)
;
return
;
}
)
;
private
readonly
=
new
Lazy
(
(
)
=>
{
const
=
.
forUris<boolean>
(
(
)
=>
this
.
)
;
.
fill
(
this
.
.
map
(
=>
[
,
true
]
)
)
;
return
;
}
)
;
private
readonly
=
new
Lazy
(
(
)
=>
{
const
=
.
forUris<boolean>
(
(
)
=>
this
.
)
;
.
fill
(
this
.
.
map
(
=>
[
,
true
]
)
)
;
return
;
}
)
;
/**
* Find out if the file change events match the provided resource.
*
* Note: when passing `FileChangeType.DELETED`, we consider a match
* also when the parent of the resource got deleted.
*/
contains
(
:
URI
,
...
:
[
]
)
:
boolean
{
return
this
.
doContains
(
,
{
:
false
}
,
...
)
;
}
/**
* Find out if the file change events either match the provided
* resource, or contain a child of this resource.
*/
affects
(
:
URI
,
...
:
[
]
)
:
boolean
{
return
this
.
doContains
(
,
{
:
true
}
,
...
)
;
}
private
doContains
(
:
URI
,
:
{
:
boolean
}
,
...
:
[
]
)
:
boolean
{
if
(
!
)
{
return
false
;
}
const
=
.
>
0
;
// Added
if
(
!
||
.
includes
(
.
ADDED
)
)
{
if
(
this
.
.
.
get
(
)
)
{
return
true
;
}
if
(
.
&&
this
.
.
.
findSuperstr
(
)
)
{
return
true
;
}
}
// Updated
if
(
!
||
.
includes
(
.
UPDATED
)
)
{
if
(
this
.
.
.
get
(
)
)
{
return
true
;
}
if
(
.
&&
this
.
.
.
findSuperstr
(
)
)
{
return
true
;
}
}
// Deleted
if
(
!
||
.
includes
(
.
DELETED
)
)
{
if
(
this
.
.
.
findSubstr
(
)
/* deleted also considers parent folders */
)
{
return
true
;
}
if
(
.
&&
this
.
.
.
findSuperstr
(
)
)
{
return
true
;
}
}
return
false
;
}
/**
* Returns if this event contains added files.
*/
gotAdded
(
)
:
boolean
{
return
this
.
.
>
0
;
}
/**
* Returns if this event contains deleted files.
*/
gotDeleted
(
)
:
boolean
{
return
this
.
.
>
0
;
}
/**
* Returns if this event contains updated files.
*/
gotUpdated
(
)
:
boolean
{
return
this
.
.
>
0
;
}
/**
* Returns if this event contains changes that correlate to the
* provided `correlationId`.
*
* File change event correlation is an advanced watch feature that
* allows to identify from which watch request the events originate
* from. This correlation allows to route events specifically
* only to the requestor and not emit them to all listeners.
*/
correlates
(
:
number
)
:
boolean
{
return
this
.
===
;
}
/**
* Figure out if the event contains changes that correlate to one
* correlation identifier.
*
* File change event correlation is an advanced watch feature that
* allows to identify from which watch request the events originate
* from. This correlation allows to route events specifically
* only to the requestor and not emit them to all listeners.
*/
hasCorrelation
(
)
:
boolean
{
return
typeof
this
.
===
'number'
;
}
/**
* @deprecated use the `contains` or `affects` method to efficiently find
* out if the event relates to a given resource. these methods ensure:
* - that there is no expensive lookup needed (by using a `TernarySearchTree`)
* - correctly handles `FileChangeType.DELETED` events
*/
readonly
:
URI
[
]
=
[
]
;
/**
* @deprecated use the `contains` or `affects` method to efficiently find
* out if the event relates to a given resource. these methods ensure:
* - that there is no expensive lookup needed (by using a `TernarySearchTree`)
* - correctly handles `FileChangeType.DELETED` events
*/
readonly
:
URI
[
]
=
[
]
;
/**
* @deprecated use the `contains` or `affects` method to efficiently find
* out if the event relates to a given resource. these methods ensure:
* - that there is no expensive lookup needed (by using a `TernarySearchTree`)
* - correctly handles `FileChangeType.DELETED` events
*/
readonly
:
URI
[
]
=
[
]
;
}
export
function
isParent
(
:
string
,
:
string
,
?
:
boolean
)
:
boolean
{
if
(
!
||
!
||
===
)
{
return
false
;
}
if
(
.
>
.
)
{
return
false
;
}
if
(
.
charAt
(
.
-
1
)
!==
)
{
+=
;
}
if
(
)
{
return
startsWithIgnoreCase
(
,
)
;
}
return
.
indexOf
(
)
===
0
;
}
export
interface
IBaseFileStat
{
/**
* The unified resource identifier of this file or folder.
*/
readonly
:
URI
;
/**
* The name which is the last segment
* of the {{path}}.
*/
readonly
:
string
;
/**
* The size of the file.
*
* The value may or may not be resolved as
* it is optional.
*/
readonly
?
:
number
;
/**
* The last modification date represented as millis from unix epoch.
*
* The value may or may not be resolved as
* it is optional.
*/
readonly
?
:
number
;
/**
* The creation date represented as millis from unix epoch.
*
* The value may or may not be resolved as
* it is optional.
*/
readonly
?
:
number
;
/**
* A unique identifier that represents the
* current state of the file or directory.
*
* The value may or may not be resolved as
* it is optional.
*/
readonly
?
:
string
;
/**
* File is readonly. Components like editors should not
* offer to edit the contents.
*/
readonly
readonly
?
:
boolean
;
/**
* File is locked. Components like editors should offer
* to edit the contents and ask the user upon saving to
* remove the lock.
*/
readonly
?
:
boolean
;
/**
* File is executable. Relevant for Unix-like systems where
* the executable bit determines if a file can be run.
*/
readonly
?
:
boolean
;
}
export
interface
IBaseFileStatWithMetadata
extends
Required<IBaseFileStat>
{
}
/**
* A file resource with meta information and resolved children if any.
*/
export
interface
IFileStat
extends
IBaseFileStat
{
/**
* The resource is a file.
*/
readonly
:
boolean
;
/**
* The resource is a directory.
*/
readonly
:
boolean
;
/**
* The resource is a symbolic link. Note: even when the
* file is a symbolic link, you can test for `FileType.File`
* and `FileType.Directory` to know the type of the target
* the link points to.
*/
readonly
:
boolean
;
/**
* The children of the file stat or undefined if none.
*/
:
[
]
|
undefined
;
}
export
interface
IFileStatWithMetadata
extends
IFileStat
,
{
readonly
:
number
;
readonly
:
number
;
readonly
:
string
;
readonly
:
number
;
readonly
readonly
:
boolean
;
readonly
:
boolean
;
readonly
:
boolean
;
readonly
:
[
]
|
undefined
;
}
export
interface
IFileStatResult
{
readonly
?
:
;
readonly
:
boolean
;
}
export
interface
IFileStatResultWithMetadata
extends
IFileStatResult
{
readonly
?
:
;
}
export
interface
IFileStatWithPartialMetadata
extends
Omit<IFileStatWithMetadata,'children'>
{
}
export
interface
IFileContent
extends
IBaseFileStatWithMetadata
{
/**
* The content of a file as buffer.
*/
readonly
:
;
}
export
interface
IFileStreamContent
extends
IBaseFileStatWithMetadata
{
/**
* The content of a file as stream.
*/
readonly
:
;
}
export
interface
IBaseReadFileOptions
extends
IFileReadStreamOptions
{
/**
* The optional etag parameter allows to return early from resolving the resource if
* the contents on disk match the etag. This prevents accumulated reading of resources
* that have been read already with the same etag.
* It is the task of the caller to makes sure to handle this error case from the promise.
*/
readonly
?
:
string
;
}
export
interface
IReadFileStreamOptions
extends
IBaseReadFileOptions
{
}
export
interface
IReadFileOptions
extends
IBaseReadFileOptions
{
/**
* The optional `atomic` flag can be used to make sure
* the `readFile` method is not running in parallel with
* any `write` operations in the same process.
*
* Typically you should not need to use this flag but if
* for example you are quickly reading a file right after
* a file event occurred and the file changes a lot, there
* is a chance that a read returns an empty or partial file
* because a pending write has not finished yet.
*
* Note: this does not prevent the file from being written
* to from a different process. If you need such atomic
* operations, you better use a real database as storage.
*/
readonly
?
:
boolean
;
}
export
interface
IWriteFileOptions
{
/**
* The last known modification time of the file. This can be used to prevent dirty writes.
*/
readonly
?
:
number
;
/**
* The etag of the file. This can be used to prevent dirty writes.
*/
readonly
?
:
string
;
/**
* Whether to attempt to unlock a file before writing.
*/
readonly
?
:
boolean
;
/**
* The optional `atomic` flag can be used to make sure
* the `writeFile` method updates the target file atomically
* by first writing to a temporary file in the same folder
* and then renaming it over the target.
*/
readonly
?
:
|
false
;
/**
* If set to true, will append to the end of the file instead of
* replacing its contents. Will create the file if it doesn't exist.
*/
readonly
?
:
boolean
;
}
export
interface
IResolveFileOptions
{
/**
* Automatically continue resolving children of a directory until the provided resources
* are found.
*/
readonly
?
:
readonly
URI
[
]
;
/**
* Automatically continue resolving children of a directory if the number of children is 1.
*/
readonly
?
:
boolean
;
/**
* Will resolve mtime, ctime, size and etag of files if enabled. This can have a negative impact
* on performance and thus should only be used when these values are required.
*/
readonly
?
:
boolean
;
}
export
interface
IResolveMetadataFileOptions
extends
IResolveFileOptions
{
readonly
:
true
;
}
export
interface
ICreateFileOptions
{
/**
* Overwrite the file to create if it already exists on disk. Otherwise
* an error will be thrown (FILE_MODIFIED_SINCE).
*/
readonly
?
:
boolean
;
}
export
class
FileOperationError
extends
Error
{
constructor
(
:
string
,
readonly
:
,
readonly
?
:
|
|
)
{
super
(
)
;
}
}
export
class
TooLargeFileOperationError
extends
FileOperationError
{
constructor
(
:
string
,
readonly
:
.
FILE_TOO_LARGE
,
readonly
:
number
,
?
:
)
{
super
(
,
,
)
;
}
}
export
class
NotModifiedSinceFileOperationError
extends
FileOperationError
{
constructor
(
:
string
,
readonly
:
,
?
:
)
{
super
(
,
.
FILE_NOT_MODIFIED_SINCE
,
)
;
}
}
export
const
enum
{
FILE_IS_DIRECTORY
,
FILE_NOT_FOUND
,
FILE_NOT_MODIFIED_SINCE
,
FILE_MODIFIED_SINCE
,
FILE_MOVE_CONFLICT
,
FILE_WRITE_LOCKED
,
FILE_PERMISSION_DENIED
,
FILE_TOO_LARGE
,
FILE_INVALID_PATH
,
FILE_NOT_DIRECTORY
,
FILE_OTHER_ERROR
}
//#endregion
//#region Settings
export
const
=
{
OFF
:
'off'
,
AFTER_DELAY
:
'afterDelay'
,
ON_FOCUS_CHANGE
:
'onFocusChange'
,
ON_WINDOW_CHANGE
:
'onWindowChange'
}
;
export
const
=
{
OFF
:
'off'
,
ON_EXIT
:
'onExit'
,
ON_EXIT_AND_WINDOW_CLOSE
:
'onExitAndWindowClose'
}
;
export
const
FILES_ASSOCIATIONS_CONFIG
=
'files.associations'
;
export
const
FILES_EXCLUDE_CONFIG
=
'files.exclude'
;
export
const
FILES_READONLY_INCLUDE_CONFIG
=
'files.readonlyInclude'
;
export
const
FILES_READONLY_EXCLUDE_CONFIG
=
'files.readonlyExclude'
;
export
const
FILES_READONLY_FROM_PERMISSIONS_CONFIG
=
'files.readonlyFromPermissions'
;
export
interface
IGlobPatterns
{
[
:
string
]
:
boolean
;
}
export
interface
IFilesConfiguration
{
?
:
;
}
export
interface
IFilesConfigurationNode
{
:
{
[
:
string
]
:
string
}
;
:
;
:
;
:
string
[
]
;
:
string
;
:
boolean
;
:
string
[
]
;
:
string
;
:
boolean
;
:
string
;
:
number
;
:
boolean
;
:
boolean
;
:
string
;
:
boolean
;
:
string
;
:
'askUser'
|
'overwriteFileOnDisk'
;
:
;
:
;
:
boolean
;
}
//#endregion
//#region Utilities
export
enum
{
FILE
,
FOLDER
,
ROOT_FOLDER
}
/**
* A hint to disable etag checking for reading/writing.
*/
export
const
ETAG_DISABLED
=
''
;
export
function
etag
(
:
{
:
number
;
:
number
}
)
:
string
;
export
function
etag
(
:
{
:
number
|
undefined
;
:
number
|
undefined
}
)
:
string
|
undefined
;
export
function
etag
(
:
{
:
number
|
undefined
;
:
number
|
undefined
}
)
:
string
|
undefined
{
if
(
typeof
.
!==
'number'
||
typeof
.
!==
'number'
)
{
return
undefined
;
}
return
.
.
toString
(
29
)
+
.
.
toString
(
31
)
;
}
export
async
function
whenProviderRegistered
(
:
URI
,
:
)
:
Promise
<
void
>
{
if
(
.
hasProvider
(
URI
.
from
(
{
:
.
}
)
)
)
{
return
;
}
return
new
Promise
(
=>
{
const
=
.
onDidChangeFileSystemProviderRegistrations
(
=>
{
if
(
.
===
.
&&
.
)
{
.
dispose
(
)
;
resolve
(
)
;
}
}
)
;
}
)
;
}
/**
* Helper to format a raw byte size into a human readable label.
*/