LordAshes-FileAccessPlugin icon

FileAccessPlugin

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

Last updated a week ago
Total downloads 896
Total rating 0 
Categories Client-side Networked Integration
Dependency string LordAshes-FileAccessPlugin-1.2.3
Dependants 3 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.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.

void SetCacheType(CacheType setting)

Used to set the cache setting for the assets file list. Four options are possible:
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).

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

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.

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-7-21 1.2.3 306 Version 1.2.3 Install
2021-7-2 1.2.1 483 Version 1.2.1 Install
2021-7-2 1.2.0 9 Version 1.2.0 Install
2021-6-29 1.1.1 52 Version 1.1.1 Install
2021-6-28 1.1.0 13 Version 1.1.0 Install
2021-6-27 1.0.0 33 Version 1.0.0 Install