LordAshes-FileAccessPlugin icon

FileAccessPlugin

Provides standardized methods for accessing both local file and url resources. Automatically handles searching local folders for assets.

Last updated 2 months ago
Total downloads 2964
Total rating 0 
Categories Tools Integration
Dependency string LordAshes-FileAccessPlugin-1.3.1
Dependants 16 other mods depend on this mod

This mod requires the following mods to function

bbepisTaleSpire-BepInExPack-5.4.10 icon
bbepisTaleSpire-BepInExPack

Unified BepInEx all-in-one modding pack - plugin framework, detour library

Preferred version: 5.4.10
brcoding-SetInjectionFlagPlugin-2.3.0 icon
brcoding-SetInjectionFlagPlugin

Allows players to flag mods are installed

Preferred version: 2.3.0

README

File Access Plugin

This unofficial TaleSpire plugin for providing a standardized method of accessing both local and internet resources (files). Plugins that use this plugin for file access will be able to access both local file resources and internet resources, without having to have different code, just by specifying a local or internet source. When using local files this plugin automatically searches plugin folders and the common folder (if present) for content which means the parent plugin does not need to worry about such details.

Change Log

1.3.1: Bug Fix: CacheSetting produces Null Exception Error 1.3.0: The SetCacheType method is marked as obsolete and does not do anything. The cache setting is now controlled at the File Access Plugin level via R2ModMan configuration setting. This prevents plugins from changing the cache setting on each other. 1.3.0: Removed unnecessary log entries 1.2.3: Catalog returns bare info by default (usable in code) with option to return extended infromation for logging purpose 1.2.1: Find returns full path if a full path source is provided 1.2.0: Supports direct path option 1.1.1: Better location of the plugins folder in case manual install was done. 1.1.0: Fixed issue with forced R2ModMan profile. Plugin now auto detects profile. 1.0.0: Initial release

Install

Install using R2ModMan or similar and reference the plugin DLL when building the parent plugin. This gives access to the LordAshes.FileAccessPlugin namespace with most of the file related functions under the sub-namespace File, some image loading function under the sub-namepace Image and an assetBundle loader under the sub-namespace of AssetBundle.

Usage

GetProtocol(string source)

Gets the protocol portion of the source. Empty string if the source is a local file or the protocol poriton (e.g. http or https) if it is a URL.

The following sub-namespaces are available...

File

AppendAllText(string source, string content)
string ReadAllText(string source)
WriteAllText(string source, string content)

Functions for appending, reading and writing the contents of the source as a single string. Note: When using a URL for the source, append and write functions perform an upload.

AppendAllLines(string source, string[] content)
string[]  ReadAllLines(string source)
WriteAllLines(string source, string[] content)

Functions for appending, reading and writing the contents of the source as an string array of lines. Each line is the source is an individual entry in the array. Note: When using a URL for the source, append and write functions perform an upload.

byte[] ReadAllBytes(string source)
WriteAllBytes(string source, byte[] content)

Functions for reading and writing the contents of the source as an byte array. Note: When using a URL for the source, append and write functions perform an upload.

bool Exists(source)

Determines if the source exists. For local files it must exists in the plugin directories or the common folder. For URL the resource needs to exists at the give source.

string[] Find(source)

When the source is a local file, finds where the source is located. Returns a string array of resources that match the given source using a "contains" concept. When using any of the append, reaad or write functions from this plugin, it is not necessary to use Find because the functions take care of that on their own. However, if using a different function to access the file, the Find function can be used to obtain the complete file path and namepace of the file.

string[] Catalog(Bool extendedData)

Returns a sorted list of all available assets sorted by type and then plugin. Setting the extendedData to true (false if omitted) will provide additional information with each entry.

Image

Texture2D LoadTexture(string source)

Returns a texture loaded with the contents of the source

Sprite LoadSprite(string source)

Returns a sprite loaded with the contents of the source. Typically used for icons.

AssetBundle

AssetBundle Load(string source)

Returns an assetBundle loaded from the specified source

Local File Search

When using local files, the source can specify a resource name or a folder and resource name and the plugin will automatically search the plugin folders for the specified resource. This allows the parent plugins to specify resources by name without having to concern themselves with figuring out which plugin contains the resource. If the installaton has the TaleSpire_CustomData folder in the main TaleSpire game folder then this folder is also used to locate assets.

This means that local access (append, read and write) is limited to writing in the plugin folders and the common folder (if it exists).

This also means that append and write functions only work with existing files. Thus the write functions cannot be used to make a new file but can be used to rewrite an existing file.

Full Path

Full path sources are recognized by having a colon as a second characters since such sources start with a drive letter and then are followed by a colon and the path and file name. When such sources are provided, they are used as is without looking them up in the files list or on the internet.

Cache Type

The Cache Type is now set for all plugins at the File Access Plugin level to avoid plugins from switching the cache type on each other. To change the cache type, edit the R2ModMan configuration for the File Access Plugin and choose on of the following option:

NoCacheCustomData = Only files in the CustomData sub-folders are collected. Contents are re-generated each time they are needed (allows adding contents on the fly). NoCacheCustomData = Only files in the CustomData sub-folders are collected. Contents are re-generated each time they are needed (allows adding contents on the fly). NoCacheFullListing = All files in plugin folders are added. Contents are re-generated each time they are needed (allows adding contents on the fly). CacheCustomData = Only files in the CustomData sub-folders are collected. Contents are generated once at startup (does not allow adding contents on the fly). CacheFullListing = All files in plugin folders are added. Contents are generated once at startup (does not allow adding contents on the fly).

Available versions

Please note that the install buttons only work if you have compatible client software installed, such as the Thunderstore Mod Manager. Otherwise use the zip download links instead.

Upload date Version number Downloads Download link  
2021-8-26 1.3.1 1218 Version 1.3.1 Install
2021-8-26 1.3.0 15 Version 1.3.0 Install
2021-7-21 1.2.3 1056 Version 1.2.3 Install
2021-7-2 1.2.1 497 Version 1.2.1 Install
2021-7-2 1.2.0 28 Version 1.2.0 Install
2021-6-29 1.1.1 70 Version 1.1.1 Install
2021-6-28 1.1.0 29 Version 1.1.0 Install
2021-6-27 1.0.0 51 Version 1.0.0 Install