default-paths.ts 509 B

1234567891011121314
  1. const FALLBACK_INSTALL_DRIVE = "D"
  2. export const DEFAULT_NOVEL_DIR_NAME = "QM-BOOK"
  3. export const DEFAULT_INSTALL_DIR_NAME = "QMaiWrite"
  4. function extractWindowsDriveLetter(pathLike: string): string | null {
  5. const match = pathLike.trim().match(/^([a-zA-Z]):[\\/]/)
  6. return match ? match[1].toUpperCase() : null
  7. }
  8. export function buildDefaultNovelDir(pathLike: string): string {
  9. const drive = extractWindowsDriveLetter(pathLike) ?? FALLBACK_INSTALL_DRIVE
  10. return `${drive}:\\${DEFAULT_NOVEL_DIR_NAME}`
  11. }