modules/fs/filesystem
Interfaces
CopyOptions
Defined in: modules/fs/filesystem.d.ts:23
Properties
overwrite?
optionaloverwrite?:boolean
Defined in: modules/fs/filesystem.d.ts:25
Overwrite the destination if it already exists.
Default
true
FileStat
Defined in: modules/fs/filesystem.d.ts:9
Normalized directory snapshot metadata record. Represents standard file or folder attributes returned during traversal passes.
Properties
isDirectory
isDirectory:
boolean
Defined in: modules/fs/filesystem.d.ts:15
Flags whether the current node represents a container directory layout branch.
name
name:
string
Defined in: modules/fs/filesystem.d.ts:11
The natural name of the node including extensions (e.g., 'index.tsx' or 'styles').
path
path:
string
Defined in: modules/fs/filesystem.d.ts:13
Complete absolute canonical layout path target (e.g., '/sdcard/project/index.tsx').
FileSystemAPI
Defined in: modules/fs/filesystem.d.ts:32
Primary Core File System API. Gives extensions platform-agnostic access to read, write, and manipulate the workspace file system.
Methods
copy()
copy(
fromPath,toPath,options?):Promise<void>
Defined in: modules/fs/filesystem.d.ts:84
Recursively copies a file or directory. Safely clones non-empty directories along with their child contents.
Parameters
fromPath
string
toPath
string
options?
Returns
Promise<void>
delete()
delete(
path):Promise<void>
Defined in: modules/fs/filesystem.d.ts:90
Recursively deletes a file or directory. Silently succeeds when the path does not exist to avoid strict disruption.
Parameters
path
string
Returns
Promise<void>
exists()
exists(
path):Promise<boolean>
Defined in: modules/fs/filesystem.d.ts:99
Checks whether a path currently exists (can be a file or a directory). *
Parameters
path
string
Returns
Promise<boolean>
Example
if (await mscode.fs.exists('/sdcard/project/.git')) {
// Git repository detected
}
mkdir()
mkdir(
path):Promise<void>
Defined in: modules/fs/filesystem.d.ts:71
Creates a directory (and any missing parent chains automatically).
Parameters
path
string
Returns
Promise<void>
readDir()
readDir(
path):Promise<FileStat[]>
Defined in: modules/fs/filesystem.d.ts:40
Lists the entries inside a directory. Returns an empty array (never throws) when the path does not exist. *
Parameters
path
string
Returns
Promise<FileStat[]>
Example
const entries = await mscode.fs.readDir('/sdcard/project/src');
const tsFiles = entries.filter(e => !e.isDirectory && e.name.endsWith('.ts'));
readFile()
readFile(
path):Promise<string>
Defined in: modules/fs/filesystem.d.ts:48
Reads a file's content. Returns raw UTF-8 string for code files, and a Base64 encoded string for binary/image files. *
Parameters
path
string
Returns
Promise<string>
Example
const json = await mscode.fs.readFile('/sdcard/project/package.json');
readJson()
readJson<
T>(path):Promise<T>
Defined in: modules/fs/filesystem.d.ts:54
Reads a file and parses it as JSON securely in one step. Throws a descriptive error when the file is missing or malformed.
Type Parameters
T
T = unknown
Parameters
path
string
Returns
Promise<T>
rename()
rename(
oldPath,newPath):Promise<void>
Defined in: modules/fs/filesystem.d.ts:78
Renames or moves a file or directory. *
Parameters
oldPath
string
newPath
string
Returns
Promise<void>
Example
await mscode.fs.rename('/sdcard/old.ts', '/sdcard/new.ts');
stat()
stat(
path):Promise<FileStat|null>
Defined in: modules/fs/filesystem.d.ts:105
Returns basic metadata for a path without reading its full memory content.
Returns null when the targeted path does not exist.
Parameters
path
string
Returns
Promise<FileStat | null>
walk()
walk(
dirPath):Promise<string[]>
Defined in: modules/fs/filesystem.d.ts:111
Recursively lists ALL files under a directory (directories themselves are excluded). Extremely useful for deep workspace searches or building syntax indexing trees.
Parameters
dirPath
string
Returns
Promise<string[]>
writeFile()
writeFile(
path,content,options?):Promise<void>
Defined in: modules/fs/filesystem.d.ts:61
Writes (or overwrites) a file. Parent directories are created automatically. *
Parameters
path
string
Absolute target file path.
content
string
Raw string or Base64 (for binary files) to save.
options?
Returns
Promise<void>
writeJson()
writeJson(
path,value,indent?):Promise<void>
Defined in: modules/fs/filesystem.d.ts:66
Serializes a JavaScript value to JSON and writes it to a file securely.
Parameters
path
string
value
unknown
indent?
number
Returns
Promise<void>
WriteOptions
Defined in: modules/fs/filesystem.d.ts:18
Properties
recursive?
optionalrecursive?:boolean
Defined in: modules/fs/filesystem.d.ts:20
Create intermediate directories if they do not exist.
Default
true
Variables
fs
constfs:FileSystemAPI
Defined in: modules/fs/filesystem.d.ts:115
References
ActivityBarItemOptions
Re-exports ActivityBarItemOptions
app
Re-exports app
authentication
Re-exports authentication
BookmarkFolder
Re-exports BookmarkFolder
CommandMetadata
Re-exports CommandMetadata
commands
Re-exports commands
CommitOptions
Re-exports CommitOptions
ConfigurationProperty
Re-exports ConfigurationProperty
Diagnostic
Re-exports Diagnostic
DiagnosticCollection
Re-exports DiagnosticCollection
DiagnosticSeverity
Re-exports DiagnosticSeverity
Disposable
Re-exports Disposable
DocumentSymbol
Re-exports DocumentSymbol
ExtensionContext
Re-exports ExtensionContext
ExtensionInfo
Re-exports ExtensionInfo
extensions
Re-exports extensions
FileDecoration
Re-exports FileDecoration
FileFilter
Re-exports FileFilter
FindOptions
Re-exports FindOptions
git
Re-exports git
GitBranch
Re-exports GitBranch
GitChangedFile
Re-exports GitChangedFile
GitCommit
Re-exports GitCommit
GitFileStatus
Re-exports GitFileStatus
GitHubUser
Re-exports GitHubUser
GitRepository
Re-exports GitRepository
GitSortMode
Re-exports GitSortMode
GitStash
Re-exports GitStash
IConfigurationSection
Re-exports IConfigurationSection
IconThemeDefinition
Re-exports IconThemeDefinition
IconThemeMap
Re-exports IconThemeMap
InputBoxOptions
Re-exports InputBoxOptions
languages
Re-exports languages
lsp
Re-exports lsp
LspServerConfig
Re-exports LspServerConfig
MenuItem
Re-exports MenuItem
menus
Re-exports menus
ModalOptions
Re-exports ModalOptions
MSCodeUIColors
Re-exports MSCodeUIColors
MultiPickerOptions
Re-exports MultiPickerOptions
NotificationAction
Re-exports NotificationAction
OutputChannel
Re-exports OutputChannel
PickerOptions
Re-exports PickerOptions
Position
Re-exports Position
ProgressNotification
Re-exports ProgressNotification
QuickPickItem
Re-exports QuickPickItem
QuickPickOptions
Re-exports QuickPickOptions
RecentWorkspace
Re-exports RecentWorkspace
ReplaceOptions
Re-exports ReplaceOptions
ResolvedIcon
Re-exports ResolvedIcon
search
Re-exports search
SearchFileResult
Re-exports SearchFileResult
SearchMatch
Re-exports SearchMatch
Selection
Re-exports Selection
SettingOption
Re-exports SettingOption
SettingType
Re-exports SettingType
SidebarPanelDef
Re-exports SidebarPanelDef
SidebarPanelHeader
Re-exports SidebarPanelHeader
SidebarSectionContent
Re-exports SidebarSectionContent
SidebarSectionContext
Re-exports SidebarSectionContext
SidebarSectionDef
Re-exports SidebarSectionDef
SidebarState
Re-exports SidebarState
SilentSearchOptions
Re-exports SilentSearchOptions
StashOptions
Re-exports StashOptions
StatusBarAlignment
Re-exports StatusBarAlignment
StatusBarItemController
Re-exports StatusBarItemController
StatusBarItemOptions
Re-exports StatusBarItemOptions
SymbolKind
Re-exports SymbolKind
SymbolProvider
Re-exports SymbolProvider
Tab
Re-exports Tab
TabDiffData
Re-exports TabDiffData
TabOptions
Re-exports TabOptions
TabType
Re-exports TabType
TaskExecution
Re-exports TaskExecution
TaskOptions
Re-exports TaskOptions
tasks
Re-exports tasks
Terminal
Re-exports Terminal
TerminalExitStatus
Re-exports TerminalExitStatus
TerminalOptions
Re-exports TerminalOptions
termis
Re-exports termis
TermisView
Re-exports TermisView
TextDocument
Re-exports TextDocument
TextEditor
Re-exports TextEditor
TextEditorEdit
Re-exports TextEditorEdit
TextEditorOptions
Re-exports TextEditorOptions
ThemeDefinition
Re-exports ThemeDefinition
themes
Re-exports themes
TokenColor
Re-exports TokenColor
TreeDataProvider
Re-exports TreeDataProvider
TreeItem
Re-exports TreeItem
TreeView
Re-exports TreeView
TreeViewOptions
Re-exports TreeViewOptions
window
Re-exports window
workspace
Re-exports workspace
WorkspaceConfiguration
Re-exports WorkspaceConfiguration
WorkspaceFolder
Re-exports WorkspaceFolder