Skip to content

Instantly share code, notes, and snippets.

@arakov
Created May 1, 2019 18:18
Show Gist options
  • Save arakov/8b73230c84f12a222447b4efa2dc2520 to your computer and use it in GitHub Desktop.
Save arakov/8b73230c84f12a222447b4efa2dc2520 to your computer and use it in GitHub Desktop.
scanning folder
import extensions;
import system'io;
import system'routines;
public vmToAsm(var s)
{
int pos := s.indexOf(0, ".");
int lastPos := pos;
while (pos != -1)
{
lastPos := pos;
pos := s.indexOf(pos + 1, ".");
};
^ s.delete(lastPos, s.Length - lastPos).add(".asm");
}
public function(var path)
{
var dir := Directory.assign(path);
dir.getFiles("*.vm").forEach:(item)
{
console.printLine(item);
using(auto writer := File.assign(vmToAsm(item)).textwriter())
{
using(auto reader := File.assign(item).textreader())
{
while (reader.Available)
{
// read the line
string line := reader.readLine();
//line := line.replace(newLine,"");
writer.writeLine(line);
}
}
}
}
}
public program()
{
function("My Folder");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment