mirror of
https://github.com/Maschell/JNUSLib.git
synced 2024-11-25 01:16:55 +01:00
Rename functions
This commit is contained in:
parent
a48f2c7547
commit
c1f6272476
@ -71,7 +71,7 @@ public class NUSTitleLoader {
|
|||||||
// If we have more than one content, the index 0 is the FST.
|
// If we have more than one content, the index 0 is the FST.
|
||||||
Content fstContent = result.getTMD().getContentByIndex(0);
|
Content fstContent = result.getTMD().getContentByIndex(0);
|
||||||
|
|
||||||
InputStream fstContentEncryptedStream = dataProvider.getInputStreamFromContent(fstContent);
|
InputStream fstContentEncryptedStream = dataProvider.readContentAsStream(fstContent);
|
||||||
|
|
||||||
byte[] fstBytes = StreamUtils.getBytesFromStream(fstContentEncryptedStream, (int) fstContent.getEncryptedFileSize());
|
byte[] fstBytes = StreamUtils.getBytesFromStream(fstContentEncryptedStream, (int) fstContent.getEncryptedFileSize());
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public class FSTDataProviderNUSTitle implements FSTDataProvider, HasNUSTitle {
|
|||||||
|
|
||||||
NUSDataProvider dataProvider = title.getDataProvider();
|
NUSDataProvider dataProvider = title.getDataProvider();
|
||||||
|
|
||||||
InputStream in = dataProvider.getInputStreamFromContent(c, streamOffset, streamFilesize);
|
InputStream in = dataProvider.readContentAsStream(c, streamOffset, streamFilesize);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
NUSDecryption nusdecryption = new NUSDecryption(title.getTicket().get());
|
NUSDecryption nusdecryption = new NUSDecryption(title.getTicket().get());
|
||||||
|
@ -44,7 +44,7 @@ public class NUSDataProviderFST implements NUSDataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStreamFromContent(Content content, long offset, long size) throws IOException {
|
public InputStream readContentAsStream(Content content, long offset, long size) throws IOException {
|
||||||
String filename = content.getFilename();
|
String filename = content.getFilename();
|
||||||
Optional<FSTEntry> contentFileOpt = FSTUtils.getChildOfDirectory(base, filename);
|
Optional<FSTEntry> contentFileOpt = FSTUtils.getChildOfDirectory(base, filename);
|
||||||
FSTEntry contentFile = contentFileOpt.orElseThrow(() -> new FileNotFoundException(filename + " was not found."));
|
FSTEntry contentFile = contentFileOpt.orElseThrow(() -> new FileNotFoundException(filename + " was not found."));
|
||||||
|
@ -45,7 +45,7 @@ public final class NUSDataProviderLocal implements NUSDataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStreamFromContent(Content content, long offset, long size) throws IOException {
|
public InputStream readContentAsStream(Content content, long offset, long size) throws IOException {
|
||||||
File filepath = FileUtils.getFileIgnoringFilenameCases(getLocalPath(), content.getFilename());
|
File filepath = FileUtils.getFileIgnoringFilenameCases(getLocalPath(), content.getFilename());
|
||||||
if (filepath == null || !filepath.exists()) {
|
if (filepath == null || !filepath.exists()) {
|
||||||
String errormsg = "Couldn't open \"" + getLocalPath() + File.separator + content.getFilename() + "\", file does not exist";
|
String errormsg = "Couldn't open \"" + getLocalPath() + File.separator + content.getFilename() + "\", file does not exist";
|
||||||
|
@ -48,7 +48,7 @@ public class NUSDataProviderLocalBackup implements NUSDataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStreamFromContent(Content content, long offset, long size) throws IOException {
|
public InputStream readContentAsStream(Content content, long offset, long size) throws IOException {
|
||||||
File filepath = new File(getFilePathOnDisk(content));
|
File filepath = new File(getFilePathOnDisk(content));
|
||||||
if (!filepath.exists()) {
|
if (!filepath.exists()) {
|
||||||
throw new FileNotFoundException(filepath.getAbsolutePath() + " was not found.");
|
throw new FileNotFoundException(filepath.getAbsolutePath() + " was not found.");
|
||||||
|
@ -37,7 +37,7 @@ public class NUSDataProviderRemote implements NUSDataProvider, Parallelizable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStreamFromContent(Content content, long fileOffsetBlock, long size) throws IOException {
|
public InputStream readContentAsStream(Content content, long fileOffsetBlock, long size) throws IOException {
|
||||||
NUSDownloadService downloadService = NUSDownloadService.getDefaultInstance();
|
NUSDownloadService downloadService = NUSDownloadService.getDefaultInstance();
|
||||||
return downloadService.getInputStreamForURL(getRemoteURL(content), fileOffsetBlock, size);
|
return downloadService.getInputStreamForURL(getRemoteURL(content), fileOffsetBlock, size);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class NUSDataProviderWUD implements NUSDataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStreamFromContent(Content content, long fileOffsetBlock, long size) throws IOException {
|
public InputStream readContentAsStream(Content content, long fileOffsetBlock, long size) throws IOException {
|
||||||
WUDDiscReader discReader = getDiscReader();
|
WUDDiscReader discReader = getDiscReader();
|
||||||
long offset = getOffsetInWUD(content) + fileOffsetBlock;
|
long offset = getOffsetInWUD(content) + fileOffsetBlock;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class NUSDataProviderWoomy implements NUSDataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStreamFromContent(@NonNull Content content, long fileOffsetBlock, long size) throws IOException {
|
public InputStream readContentAsStream(@NonNull Content content, long fileOffsetBlock, long size) throws IOException {
|
||||||
WoomyZipFile zipFile = getSharedWoomyZipFile();
|
WoomyZipFile zipFile = getSharedWoomyZipFile();
|
||||||
ZipEntry entry = getWoomyInfo().getContentFiles().get(content.getFilename().toLowerCase());
|
ZipEntry entry = getWoomyInfo().getContentFiles().get(content.getFilename().toLowerCase());
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
|
@ -27,19 +27,19 @@ import de.mas.wiiu.jnus.utils.StreamUtils;
|
|||||||
|
|
||||||
public interface NUSDataProvider {
|
public interface NUSDataProvider {
|
||||||
|
|
||||||
default public byte[] getChunkFromContent(Content content, long offset, int size) throws IOException {
|
default public byte[] readContent(Content content, long offset, int size) throws IOException {
|
||||||
return StreamUtils.getBytesFromStream(getInputStreamFromContent(content, offset, size), size);
|
return StreamUtils.getBytesFromStream(readContentAsStream(content, offset, size), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
default public InputStream getInputStreamFromContent(Content content) throws IOException {
|
default public InputStream readContentAsStream(Content content) throws IOException {
|
||||||
return getInputStreamFromContent(content, 0);
|
return readContentAsStream(content, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
default public InputStream getInputStreamFromContent(Content content, long offset) throws IOException {
|
default public InputStream readContentAsStream(Content content, long offset) throws IOException {
|
||||||
return getInputStreamFromContent(content, offset, content.getEncryptedFileSize() - offset);
|
return readContentAsStream(content, offset, content.getEncryptedFileSize() - offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getInputStreamFromContent(Content content, long offset, long size) throws IOException;
|
public InputStream readContentAsStream(Content content, long offset, long size) throws IOException;
|
||||||
|
|
||||||
public Optional<byte[]> getContentH3Hash(Content content) throws IOException;
|
public Optional<byte[]> getContentH3Hash(Content content) throws IOException;
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public class DataProviderUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Utils.createDir(outputFolder);
|
Utils.createDir(outputFolder);
|
||||||
InputStream inputStream = dataProvider.getInputStreamFromContent(content);
|
InputStream inputStream = dataProvider.readContentAsStream(content);
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
log.warning(content.getFilename() + " Couldn't save encrypted content. Input stream was null");
|
log.warning(content.getFilename() + " Couldn't save encrypted content. Input stream was null");
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user