Skip to content

Commit

Permalink
music: support m3u absolute paths
Browse files Browse the repository at this point in the history
Under the assumption they are in the same volume as the file. It's
hacky, but whatever.
  • Loading branch information
OxygenCobalt committed Dec 20, 2023
1 parent c66a9b1 commit c995eb0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/src/main/java/org/oxycblt/auxio/music/external/M3U.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.oxycblt.auxio.music.fs.Components
import org.oxycblt.auxio.music.fs.Path
import org.oxycblt.auxio.music.metadata.correctWhitespace
import org.oxycblt.auxio.util.logW
import java.io.File

/**
* Minimal M3U file format implementation.
Expand Down Expand Up @@ -85,10 +86,19 @@ class M3UImpl @Inject constructor() : M3U {
}

// 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.
val relativeComponents = Components.parse(path)
val absoluteComponents =
resolveRelativePath(relativeComponents, workingDirectory.components)
val components = Components.parse(path)
val absoluteComponents = if (path.startsWith(File.separatorChar)) {
// 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))
}
Expand Down

0 comments on commit c995eb0

Please sign in to comment.