Class Disk
java.lang.Object
net.buildtheearth.terraminusminus.util.http.Disk
Handles disk I/O operations for
Http.-
Method Summary
Modifier and TypeMethodDescriptionstatic PathcacheFileFor(@NonNull String url) Gets the file path which stores the cached data for the given url.static PathconfigFile(@NonNull String name) Gets the path to an additional configuration file with the given name.static CompletableFuture<io.netty.buffer.ByteBuf> Asynchronously reads a file's contents into aByteBuf.static voidsetCacheRoot(@NonNull File cacheDir) Set the directory where Terra-- should store its HTTP cache files.static voidsetConfigRoot(@NonNull File configDir) Set the directory where Terra-- should look for configuration files likeosm.json5orheights.json5.static voidAsynchronously writes a file's contents, replacing the existing file if it already exists.
-
Method Details
-
setCacheRoot
Set the directory where Terra-- should store its HTTP cache files.
The cache root can only be set once. As a consequence, calling this methode multiple times will result in anIllegalStateExceptionbeing thrown.
If this is not manually called before using any method that makes use of the cache, the cache root will be automatically set to$CWD/terraminusminus/cache, and further attempts to call this method will result in anIllegalStateExceptionbeing thrown.
This method and its implementation are unique to Terra--, as Terra++ is hardcoded to use.minecraft/terraplusplus/cache.- Parameters:
cacheDir- the root of the cache- Throws:
IllegalStateException
-
setConfigRoot
Set the directory where Terra-- should look for configuration files likeosm.json5orheights.json5.
The config root can only be set once. As a consequence, calling this methode multiple times will result in anIllegalStateExceptionbeing thrown.
If this is not manually called before Terra-- needs to load a configuration file, the config root will be automatically set to$CWD/terraminusminus/config, and further attempts to call this method will result in anIllegalStateExceptionbeing thrown.
This method and its implementation are unique to Terra--, as Terra++ is hardcoded to use.minecraft/terraplusplus/config.- Parameters:
configDir- the root of the cache
-
read
Asynchronously reads a file's contents into aByteBuf.- Parameters:
file- the file- Returns:
- a
CompletableFuturewhich will be notified when the file has been read
-
write
public static void write(@NonNull @NonNull Path file, @NonNull @NonNull io.netty.buffer.ByteBuf data) Asynchronously writes a file's contents, replacing the existing file if it already exists.- Parameters:
file- the filedata- the data
-
cacheFileFor
Gets the file path which stores the cached data for the given url.- Parameters:
url- the url- Returns:
- the cache file
-
configFile
Gets the path to an additional configuration file with the given name.- Parameters:
name- the configuration file's name- Returns:
- the path to the configuration file
-