2016-09-06 21:11:17 +01:00
|
|
|
import os
|
|
|
|
|
|
|
|
echo("Input KSM directory")
|
|
|
|
let mainDir: string = readLine(stdin)
|
2016-09-06 21:20:03 +01:00
|
|
|
var playerName: string = ""
|
|
|
|
echo("If your ingame player name is not 'PLAYER' enter it now (otherwise press enter)")
|
|
|
|
playerName = readLine(stdin)
|
|
|
|
if playerName == "":
|
|
|
|
playerName = "PLAYER"
|
2018-12-25 19:44:45 +00:00
|
|
|
let userDir: string = mainDir & DirSep & "score" & DirSep & playerName
|
2016-09-06 21:11:17 +01:00
|
|
|
let outFileName: string = mainDir & DirSep & "songs" & DirSep & "Played.fav"
|
|
|
|
var f: File
|
|
|
|
if open(f, outFileName, fmWrite):
|
|
|
|
try:
|
|
|
|
for kind, path in walkDir(userDir, true):
|
|
|
|
if kind == pcDir:
|
|
|
|
let fullPath = userDir & DirSep & path
|
|
|
|
for k2, p2 in walkDir(fullPath, true):
|
|
|
|
if k2 == pcDir:
|
2018-12-25 19:44:45 +00:00
|
|
|
f.write(path & "\\" & p2)
|
|
|
|
# KSM can only read Windows style line endings
|
|
|
|
f.write('\r')
|
|
|
|
f.write('\n')
|
2016-09-06 21:11:17 +01:00
|
|
|
finally:
|
|
|
|
close(f)
|
|
|
|
else:
|
|
|
|
quit("Error writing to file: " & outFileName)
|