1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-13 17:34:13 +02:00

Merge pull request #1487 from cyian-1756/windows-pathname-fixes

Fixed path name issues on windows
This commit is contained in:
cyian-1756
2019-11-29 06:59:38 -05:00
committed by GitHub
2 changed files with 7 additions and 7 deletions

View File

@@ -870,8 +870,6 @@ public class Utils {
// How long the path without the file name is
int pathLength = ripsDirPath.length();
int fileNameLength = fileName.length();
LOGGER.info(pathLength);
LOGGER.info(fileNameLength);
if (pathLength == 260) {
// We've reached the max length, there's nothing more we can do
throw new FileNotFoundException("File path is too long for this OS");
@@ -881,8 +879,8 @@ public class Utils {
// file extension
String fileExt = saveAsSplit[saveAsSplit.length - 1];
// The max limit for paths on Windows is 260 chars
LOGGER.info(fullPath.substring(0, 260 - pathLength - fileExt.length() + 1) + "." + fileExt);
fullPath = fullPath.substring(0, 260 - pathLength - fileExt.length() + 1) + "." + fileExt;
LOGGER.info(fullPath.substring(0, 259 - pathLength - fileExt.length() + 1) + "." + fileExt);
fullPath = fullPath.substring(0, 259 - pathLength - fileExt.length() + 1) + "." + fileExt;
LOGGER.info(fullPath);
LOGGER.info(fullPath.length());
return new File(fullPath);

View File

@@ -7,10 +7,12 @@ import java.util.Arrays;
import com.rarchives.ripme.utils.Utils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class UtilsTest {
public void testGetEXTFromMagic() {
public void testGetEXTFromMagic()
{
Assertions.assertEquals("jpeg", Utils.getEXTFromMagic(new byte[] { -1, -40, -1, -37, 0, 0, 0, 0 }));
Assertions.assertEquals("png", Utils.getEXTFromMagic(new byte[] { -119, 80, 78, 71, 13, 0, 0, 0 }));
}
@@ -44,13 +46,13 @@ public class UtilsTest {
public void testBetween() {
Assertions.assertEquals(Arrays.asList(" is a "), Utils.between("This is a test", "This", "test"));
}
@Test
public void testShortenFileNameWindows() throws FileNotFoundException {
String filename = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff.png";
// Test filename shortening for windows
File f = Utils.shortenSaveAsWindows("D:/rips/test/reddit/deep", filename);
Assertions.assertEquals(new File(
"D:/rips/test/reddit/deep/fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff.png"),
"D:/rips/test/reddit/deep/ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff.png"),
f);
}