-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
124 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,50 @@ | ||
import { MoonlightFS } from "@moonlight-mod/types"; | ||
import type { MoonlightFS } from "@moonlight-mod/types"; | ||
import requireImport from "./util/import"; | ||
|
||
export default function getFS(): MoonlightFS { | ||
browser: { | ||
return window._moonlightBrowserFS!; | ||
} | ||
export default function createFS(): MoonlightFS { | ||
const fs = requireImport("fs"); | ||
const path = requireImport("path"); | ||
|
||
nodeTarget: { | ||
const fs = requireImport("fs"); | ||
const path = requireImport("path"); | ||
return { | ||
async readFile(path) { | ||
const file = fs.readFileSync(path); | ||
return new Uint8Array(file); | ||
}, | ||
async readFileString(path) { | ||
return fs.readFileSync(path, "utf8"); | ||
}, | ||
async writeFile(path, data) { | ||
fs.writeFileSync(path, Buffer.from(data)); | ||
}, | ||
async writeFileString(path, data) { | ||
fs.writeFileSync(path, data, "utf8"); | ||
}, | ||
async unlink(path) { | ||
fs.unlinkSync(path); | ||
}, | ||
|
||
return { | ||
async readFile(path) { | ||
const file = fs.readFileSync(path); | ||
return new Uint8Array(file); | ||
}, | ||
async readFileString(path) { | ||
return fs.readFileSync(path, "utf8"); | ||
}, | ||
async writeFile(path, data) { | ||
fs.writeFileSync(path, Buffer.from(data)); | ||
}, | ||
async writeFileString(path, data) { | ||
fs.writeFileSync(path, data, "utf8"); | ||
}, | ||
async unlink(path) { | ||
fs.unlinkSync(path); | ||
}, | ||
async readdir(path) { | ||
return fs.readdirSync(path); | ||
}, | ||
async mkdir(path) { | ||
fs.mkdirSync(path, { recursive: true }); | ||
}, | ||
async rmdir(path) { | ||
fs.rmSync(path, { recursive: true }); | ||
}, | ||
|
||
async readdir(path) { | ||
return fs.readdirSync(path); | ||
}, | ||
async mkdir(path) { | ||
fs.mkdirSync(path, { recursive: true }); | ||
}, | ||
async rmdir(path) { | ||
fs.rmSync(path, { recursive: true }); | ||
}, | ||
async exists(path) { | ||
return fs.existsSync(path); | ||
}, | ||
async isFile(path) { | ||
return fs.statSync(path).isFile(); | ||
}, | ||
|
||
async exists(path) { | ||
return fs.existsSync(path); | ||
}, | ||
async isFile(path) { | ||
return fs.statSync(path).isFile(); | ||
}, | ||
|
||
join(...parts) { | ||
return path.join(...parts); | ||
}, | ||
dirname(dir) { | ||
return path.dirname(dir); | ||
} | ||
}; | ||
} | ||
join(...parts) { | ||
return path.join(...parts); | ||
}, | ||
dirname(dir) { | ||
return path.dirname(dir); | ||
} | ||
}; | ||
} |
Oops, something went wrong.