music: support m3u absolute paths
Under the assumption they are in the same volume as the file. It's hacky, but whatever.
This commit is contained in:
parent
c66a9b19b5
commit
c995eb0d04
1 changed files with 13 additions and 3 deletions
|
@ -26,6 +26,7 @@ import org.oxycblt.auxio.music.fs.Components
|
||||||
import org.oxycblt.auxio.music.fs.Path
|
import org.oxycblt.auxio.music.fs.Path
|
||||||
import org.oxycblt.auxio.music.metadata.correctWhitespace
|
import org.oxycblt.auxio.music.metadata.correctWhitespace
|
||||||
import org.oxycblt.auxio.util.logW
|
import org.oxycblt.auxio.util.logW
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimal M3U file format implementation.
|
* Minimal M3U file format implementation.
|
||||||
|
@ -85,10 +86,19 @@ class M3UImpl @Inject constructor() : M3U {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The path may be relative to the directory that the M3U file is contained in,
|
// The path may be relative to the directory that the M3U file is contained in,
|
||||||
|
// signified by either the typical ./ or the absence of any separator at all.
|
||||||
// so we may need to resolve it into an absolute path before moving ahead.
|
// so we may need to resolve it into an absolute path before moving ahead.
|
||||||
val relativeComponents = Components.parse(path)
|
val components = Components.parse(path)
|
||||||
val absoluteComponents =
|
val absoluteComponents = if (path.startsWith(File.separatorChar)) {
|
||||||
resolveRelativePath(relativeComponents, workingDirectory.components)
|
// Already an absolute path, do nothing. Theres still some relative-ness here,
|
||||||
|
// as we assume that the path is still in the same volume as the working directory.
|
||||||
|
// Unsure if any program goes as far as writing out the full unobfuscated
|
||||||
|
// absolute path.
|
||||||
|
components
|
||||||
|
} else {
|
||||||
|
// Relative path, resolve it
|
||||||
|
resolveRelativePath(components, workingDirectory.components)
|
||||||
|
}
|
||||||
|
|
||||||
paths.add(Path(workingDirectory.volume, absoluteComponents))
|
paths.add(Path(workingDirectory.volume, absoluteComponents))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue