-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export system_cwd, hopefully the final form of get_dirs()
Fix read() for non-existent files Prepare for Windows-POSIX path conversions, though I didn't do the actual conversions yet Update to Typescript 5.4, and embed the few ansi-escapes we were using, because of sindresorhus/ansi-escapes#29
- Loading branch information
1 parent
20366f0
commit 928d602
Showing
8 changed files
with
112 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Common Dialog functions | ||
======================= | ||
Copyright (c) 2024 Dannii Willis | ||
MIT licenced | ||
https://github.com/curiousdannii/asyncglk | ||
*/ | ||
|
||
import {FileType} from '../../common/protocol.js' | ||
|
||
/** File extensions for Glk file types */ | ||
export function filetype_to_extension(filetype: FileType): string { | ||
switch (filetype) { | ||
case 'command': | ||
case 'transcript': | ||
return 'txt' | ||
case 'data': | ||
return 'glkdata' | ||
case 'save': | ||
return 'glksave' | ||
default: | ||
return 'glkdata' | ||
} | ||
} | ||
|
||
/** Construct a file-filter list for a given usage type. */ | ||
export function filters_for_usage(usage: string | null) { | ||
switch (usage) { | ||
case 'data': | ||
return [ { name: 'Glk Data File', extensions: ['glkdata'] } ] | ||
case 'save': | ||
return [ { name: 'Glk Save File', extensions: ['glksave'] } ] | ||
case 'transcript': | ||
return [ { name: 'Transcript File', extensions: ['txt'] } ] | ||
case 'command': | ||
return [ { name: 'Command File', extensions: ['txt'] } ] | ||
default: | ||
return [] | ||
} | ||
} | ||
|
||
/** Convert a native path to a POSIX path */ | ||
export function path_native_to_posix(path: string): string { | ||
if (process.platform === 'win32') { | ||
throw new Error('not implemented') | ||
} | ||
else { | ||
return path | ||
} | ||
} | ||
|
||
/** Convert a POSIX path to a native path */ | ||
export function path_posix_to_native(path: string): string { | ||
if (process.platform === 'win32') { | ||
throw new Error('not implemented') | ||
} | ||
else { | ||
return path | ||
} | ||
} |
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