forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaths.ts
More file actions
24 lines (21 loc) · 760 Bytes
/
Copy pathpaths.ts
File metadata and controls
24 lines (21 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { app } from 'electron'
import { join } from 'path'
import { mkdirSync } from 'fs'
/** Root dir for rewind JPEGs: <userData>/rewind */
export function rewindRoot(): string {
return join(app.getPath('userData'), 'rewind')
}
/** Per-day subdir (YYYY-MM-DD), created if missing. */
export function rewindDayDir(tsMs: number): string {
const d = new Date(tsMs)
const day = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(
d.getDate()
).padStart(2, '0')}`
const dir = join(rewindRoot(), day)
mkdirSync(dir, { recursive: true })
return dir
}
/** Absolute path for a frame's JPEG: <root>/<day>/<ts>.jpg */
export function rewindFramePath(tsMs: number): string {
return join(rewindDayDir(tsMs), `${tsMs}.jpg`)
}