FileSystem¶
File system operations for reading and writing files.
FileSystem
¶
VS Code file system operations.
Source code in vscode_sockpuppet/fs.py
read_file
¶
Read a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI of the file to read |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The file contents as bytes |
write_file
¶
Write to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI of the file to write |
required |
content
|
bytes
|
The content to write |
required |
delete
¶
Delete a file or directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI of the file/directory to delete |
required |
recursive
|
bool
|
Delete recursively if a directory |
False
|
use_trash
|
bool
|
Use the OS trash/recycle bin |
False
|
Source code in vscode_sockpuppet/fs.py
rename
¶
Rename/move a file or directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Source URI |
required |
target
|
str
|
Target URI |
required |
overwrite
|
bool
|
Overwrite if target exists |
False
|
Source code in vscode_sockpuppet/fs.py
copy
¶
Copy a file or directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Source URI |
required |
target
|
str
|
Target URI |
required |
overwrite
|
bool
|
Overwrite if target exists |
False
|
Source code in vscode_sockpuppet/fs.py
create_directory
¶
Create a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI of the directory to create |
required |
read_directory
¶
Read a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI of the directory to read |
required |
Returns:
| Type | Description |
|---|---|
List[Tuple[str, int]]
|
List of (name, type) tuples where type is from FileType |
Source code in vscode_sockpuppet/fs.py
stat
¶
Get file metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI of the file |
required |
Returns:
| Type | Description |
|---|---|
FileStat
|
File metadata |
read_text
¶
Read a text file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI of the file |
required |
encoding
|
str
|
Text encoding (default: utf-8) |
'utf-8'
|
Returns:
| Type | Description |
|---|---|
str
|
File contents as string |
Source code in vscode_sockpuppet/fs.py
write_text
¶
Write a text file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI of the file |
required |
text
|
str
|
Text content to write |
required |
encoding
|
str
|
Text encoding (default: utf-8) |
'utf-8'
|
Source code in vscode_sockpuppet/fs.py
exists
¶
Check if a file or directory exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if exists, False otherwise |
Source code in vscode_sockpuppet/fs.py
is_directory
¶
Check if a URI points to a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if directory, False otherwise |
Source code in vscode_sockpuppet/fs.py
is_file
¶
Check if a URI points to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The URI to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if file, False otherwise |
Source code in vscode_sockpuppet/fs.py
FileStat¶
FileStat
¶
FileType¶
FileType
¶
File type enumeration.