Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial try at a Mac implementation #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions core/js/src/main/scala/tf/bug/dirs/MacPlatform.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package tf.bug.dirs

import java.nio.file.{Path, Paths}

object MacPlatform extends Mac {
def home: Option[Path] = Some(Paths.get(os.homedir()))
def cache: Option[Path] = home.map(h => Paths.get(h + "/Library/)Caches"))
def config: Option[Path] =
home.map(h => Paths.get(h + "/Library/)Application Support"))
def data: Option[Path] =
home.map(h => Paths.get(h + "/Library/)Application Support"))
def dataLocal: Option[Path] =
home.map(h => Paths.get(h + "/Library/)Preferences"))
def preference: Option[Path] =
home.map(h => Paths.get(h + "/Library/)Preferences"))
def audio: Option[Path] = home.map(h => Paths.get(h + "/Music"))
def desktop: Option[Path] = home.map(h => Paths.get(h + "/Desktop"))
def document: Option[Path] = home.map(h => Paths.get(h + "/Documents"))
def download: Option[Path] = home.map(h => Paths.get(h + "/Downloads"))
def font: Option[Path] = home.map(h => Paths.get(h + "/Library/)Fonts"))
def picture: Option[Path] = home.map(h => Paths.get(h + "/Pictures"))
def public: Option[Path] = home.map(h => Paths.get(h + "/Public"))
def video: Option[Path] = home.map(h => Paths.get(h + "/Movies"))
}
13 changes: 13 additions & 0 deletions core/js/src/main/scala/tf/bug/dirs/os.scala.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package tf.bug.dirs

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

/**
* Necessary facades around the Node.js `os` module for discovering dirs
*/
object os {
zetashift marked this conversation as resolved.
Show resolved Hide resolved
@js.native
@JSImport("os", "homedir")
def homedir(): String = js.native
}
34 changes: 20 additions & 14 deletions core/jvm/src/main/scala/tf/bug/dirs/MacPlatform.scala
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package tf.bug.dirs

import java.nio.file.{Path, Paths}

object MacPlatform extends Mac {
def home: Option[Path] = System.getProperty("user.home")
def cache: Option[Path] = home.map(h => h + "/Library/Caches")
def config: Option[Path] = home.map(h => h + "/Library/Application Support")
def data: Option[Path] = home.map(h => h + "/Library/Application Support")
def dataLocal: Option[Path] = home.map(h => h + "/Library/Preferences" )
def preference: Option[Path] = home.map(h => h + "/Library/Preferences")
def audio: Option[Path] = home.map(h => h + "/Music")
def desktop: Option[Path] = home.map(h => h + "/Desktop")
def document: Option[Path] = home.map(h => h + "/Documents")
def download: Option[Path] = home.map(h => h + "/Downloads")
def font: Option[Path] = home.map(h => h + "/Library/Fonts")
def picture: Option[Path] = home.map(h => h + "/Pictures")
def public: Option[Path] = home.map(h => h + "/Public")
def video: Option[Path] = home.map(h => h + "/Movies")
def home: Option[Path] = Some(Paths.get(System.getProperty("user.home")))
def cache: Option[Path] = home.map(h => Paths.get(h + "/Library/)Caches"))
def config: Option[Path] =
home.map(h => Paths.get(h + "/Library/)Application Support"))
def data: Option[Path] =
home.map(h => Paths.get(h + "/Library/)Application Support"))
def dataLocal: Option[Path] =
home.map(h => Paths.get(h + "/Library/)Preferences"))
zetashift marked this conversation as resolved.
Show resolved Hide resolved
def preference: Option[Path] =
home.map(h => Paths.get(h + "/Library/)Preferences"))
def audio: Option[Path] = home.map(h => Paths.get(h + "/Music"))
def desktop: Option[Path] = home.map(h => Paths.get(h + "/Desktop"))
def document: Option[Path] = home.map(h => Paths.get(h + "/Documents"))
def download: Option[Path] = home.map(h => Paths.get(h + "/Downloads"))
def font: Option[Path] = home.map(h => Paths.get(h + "/Library/)Fonts"))
def picture: Option[Path] = home.map(h => Paths.get(h + "/Pictures"))
def public: Option[Path] = home.map(h => Paths.get(h + "/Public"))
def video: Option[Path] = home.map(h => Paths.get(h + "/Movies"))
}