overwolf.extensions.io API
Use this API to get I/O functionalities for the current extension and access your extension's dedicated storage space like the pictures folder, videos folder, or appData folder.
For general I/O functionalities, use the overwolf.io API. In addition, the simple I/O plugin offers several more general I/O features that are not available through the APIs.
Methods Reference
- overwolf.extensions.io.createDirectory()
- overwolf.extensions.io.getStoragePath()
- overwolf.extensions.io.exist()
- overwolf.extensions.io.move()
- overwolf.extensions.io.delete()
- overwolf.extensions.io.copy()
- overwolf.extensions.io.dir()
- overwolf.extensions.io.readTextFile()
- overwolf.extensions.io.writeTextFile()
Types Reference
- overwolf.extensions.io.enums.FileType enum
- overwolf.extensions.io.enums.StorageSpace enum
- overwolf.extensions.io.Content Object
- overwolf.extensions.io.ReadTextFileResult Object
- overwolf.extensions.io.ExistResult Object
- overwolf.extensions.io.GetStoragePathResult Object
- overwolf.extensions.io.DirResult Object
- overwolf.extensions.io.DeleteResult Object
createDirectory(space, path, callback)
Version added: 0.147
Create directory.
Parameter | Type | Description |
---|---|---|
space | StorageSpace enum | The selected storage space. |
path | string | Path within the space. Use null or empty string for the space root. |
callback | (Result) => void | Reports success or failure. |
Usage example
overwolf.extensions.io.createDirectory(overwolf.extensions.io.enums.StorageSpace.appData,"hal9000",console.log)
//==> {success: true}
getStoragePath(space, callback)
Version added: 0.147
Returns the full path of given extension storage space.
Parameter | Type | Description |
---|---|---|
space | StorageSpace enum | The selected storage space. |
callback | (Result: GetStoragePathResult) => void | Returns with the full path of the requested extension storage space |
Usage example
overwolf.extensions.io.getStoragePath(overwolf.extensions.io.enums.StorageSpace.appData,console.log)
//==>{path: "C:\Users\Hal9000\AppData\Roaming\Overwolf\nhmkaollkcmjiecdnnjmgfifjgkfegkljnjjbipp", success: true}
exist(space, path, callback)
Version added: 0.147
Returns whether the file or folder specified exist.
Parameter | Type | Description |
---|---|---|
space | StorageSpace enum | The selected storage space. |
path | string | Path within the space. Use null or empty string for the space root. |
callback | (Result: ExistResult) => void | Returns with the type of the file (if exist). |
Usage example
overwolf.extensions.io.exist(overwolf.extensions.io.enums.StorageSpace.appData,"hal9000",console.log)
//==> "{type": "directory", "success":true}
//you can use full path as well (just add escape slash for backslash)
overwolf.extensions.io.exist(overwolf.extensions.io.enums.StorageSpace.appData,"C:\\Users\\OWUser\\AppData\\Roaming\\Overwolf\\nhmkaollkcmjiecdnnjmgfifjgkfegkljnjjbipp\\hal9000",console.log)
//==> "{type": "directory", "success":true}
move(space, source, destination, callback)
Version added: 0.147
Moves source file or directory and its contents to destination.
Parameter | Type | Description |
---|---|---|
space | StorageSpace enum | The selected storage space. |
source | string | Path for the source. |
destination | string | Path to move to, including filename. |
callback | (Result) => void | Reports success or failure. |
Usage example
overwolf.extensions.io.move(overwolf.extensions.io.enums.StorageSpace.appData,"hal9000\\log.txt","log.txt",console.log)
//==>{"success":true}
delete(space, path, callback)
Version added: 0.147
Deletes file or directory and its contents.
Parameter | Type | Description |
---|---|---|
space | StorageSpace enum | The selected storage space. |
path | string | Path within the space. Use null or empty string for the space root. |
callback | (Result: DeleteResult) => void | Returns with array of file and directory paths that could not be deleted. |
Usage example
overwolf.extensions.io.delete(overwolf.extensions.io.enums.StorageSpace.appData,"log.txt",console.log)
//==>{success: true}
To delete old videos you can use overwolf.media.videos.deleteOldVideos(), and to delete old gifs you can use overwolf.media.deleteOldGifs().
copy(space, source, destination, callback)
Version added: 0.147
Copies source file or directory and its contents to destination.
Parameter | Type | Description |
---|---|---|
space | StorageSpace enum | The selected storage space. |
source | string | Path for the source. |
destination | string | Path to copy to, including filename. |
callback | (Result) => void | Reports success or failure. |
Usage example
overwolf.extensions.io.copy(overwolf.extensions.io.enums.StorageSpace.appData,"hal9000\\log.txt","log.txt",console.log)
//==>{"success":true}
dir(space, directoryPath, callback)
Version added: 0.147
Lists directories and files under given directory path.
Parameter | Type | Description |
---|---|---|
space | StorageSpace enum | The selected storage space. |
directoryPath | string | Path within the space. Use null or empty string for the space root. |
callback | (Result: DirResult) => void | Returns with array of file names within the directory. |
Usage example
overwolf.extensions.io.dir(overwolf.extensions.io.enums.StorageSpace.appData,"",console.log)
//==>{"files":[],"directories":["hal9000"],"success":true}
readTextFile(space, filePath, callback)
Version added: 0.147
Returns the content of a given file.
Parameter | Type | Description |
---|---|---|
space | StorageSpace enum | The selected storage space. |
filePath | string | Path of a file to read (within the space). |
callback | (Result: ReadTextFileResult) => void | Returns with the content of the fil. |
Usage example
overwolf.extensions.io.readTextFile(overwolf.extensions.io.enums.StorageSpace.appData,"hal9000\\loxg.txt",console.log)
writeTextFile(space, filePath, content, callback)
Version added: 0.147
Writes the provided text content to the provided file.
Parameter | Type | Description |
---|---|---|
space | StorageSpace enum | The selected storage space. |
filePath | string | Path of a file to write to (within the space). |
content | string | Text content to write (added to the end of file, not overwrite the content) |
callback | (Result) => void | Reports success or failure. |
Usage example
overwolf.extensions.io.writeTextFile(overwolf.extensions.io.enums.StorageSpace.appData,"hal9000\\log.txt","add this to your tail",console.log)
//==>{"success":true}
FileType enum
Version added: 0.147
FileType is "file"|"directory".
Option | Description |
---|---|
file | |
directory |
StorageSpace enum
Version added: 0.147
The selected storage space.
Note that the default Overwolf's captured pictures and videos folder is the windows "pictures"/"videos" folder.
Of course, the user can change it anytime from the OW client UI.
Option | Description |
---|---|
pictures | The extension's captured pictures folder, OverwolfPicturesFolder\AppName\ |
videos | The extension's captured videos folder, OverwolfVideosFolder\AppName\ |
appData | The extension's folder under Roaming app data, AppData\Roaming\Overwolf\[Extensions UID] |
Content Object
Version added: 0.147
Parameter | Type | Description |
---|---|---|
type | FileType enum | FileType is "file" or "directory". |
path | string |
ReadTextFileResult Object
Version added: 0.147
Parameter | Type | Description |
---|---|---|
status | string | deprecated. For backward compatibility only |
Reason | string | deprecated. For backward compatibility only |
content | string |
Example data: Success
{"content":"just a demo text","success":true}
Example data: Failure
{
"success":false,
"error":"hal9000\\loxg.txt does not exist."
}
ExistResult Object
Version added: 0.147
Parameter | Type | Description |
---|---|---|
status | string | deprecated. For backward compatibility only |
Reason | string | deprecated. For backward compatibility only |
type | FileType enum | FileType is "file" or "directory". |
Example data: Success
"{type": "directory", "success":true}
Example data: Failure
{
"type": "file",
"success": false,
"error": "C:\Users\hal9000\AppData\Roaming\Overwolf\nhm…dnnjmgfifjgkfegkljnjjbipp\DirNameX does not exist."
}
GetStoragePathResult Object
Version added: 0.147
Parameter | Type | Description |
---|---|---|
status | string | deprecated. For backward compatibility only |
Reason | string | deprecated. For backward compatibility only |
path | string | Full path of the requested extension storage space |
Example data: Success
//the path of the extension's app data storage space
{
"path": "C:\Users\Hal9000\AppData\Roaming\Overwolf\nhmkaollkcmjiecdnnjmgfifjgkfegkljnjjbipp",
"success": true
}
Example data: Failure
DirResult Object
Version added: 0.147
Parameter | Type | Description |
---|---|---|
status | string | deprecated. For backward compatibility only |
Reason | string | deprecated. For backward compatibility only |
files | string[] | Array of file names within the directory. |
directories | string[] | Array of directory names within the directory. |
Example data: Success
{
"files":["hal9000\\log.txt"],
"directories":[],
"success":true
}
Example data: Failure
{
"success":false,
"error":"Could not find a part of the path 'C:\\Users\\OWUser\\AppData\\Roaming\\Overwolf\\nhmkaollkcmjiecdnnjmgfifjgkfegkljnjjbipp\\hal900'."
}
DeleteResult Object
Version added: 0.147
Parameter | Type | Description |
---|---|---|
success | boolean | inherited from the "Result" Object |
error | string | inherited from the "Result" Object |
status | string | deprecated. For backward compatibility only |
Reason | string | deprecated. For backward compatibility only |
undeleted_content | Content[] | Array of file and directory paths that could not be deleted. |
Example data: Success
{"success": "true"}
Example data: Failure
{
"success": false,
"error": "File or directory do not exist"
}