mirror of
https://github.com/avinal/The-VM-to-HACK-Translator.git
synced 2026-01-09 22:58:33 +05:30
added filesystem
This commit is contained in:
30
Main.cpp
30
Main.cpp
@@ -1,9 +1,37 @@
|
||||
#include "code_writer.hpp"
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
code_writer toassembly(argv[1]);
|
||||
lots_of_files files;
|
||||
std::string input(argv[1]);
|
||||
if (fs::is_directory(input))
|
||||
{
|
||||
files.push_back(input);
|
||||
for (auto &entry : fs::directory_iterator(input))
|
||||
{
|
||||
if (entry.path().extension() == ".vm")
|
||||
{
|
||||
std::string vmfile = entry.path().string();
|
||||
if (entry.path().filename() == "Sys.vm")
|
||||
{
|
||||
files.insert(files.begin() + 1, vmfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
files.push_back(vmfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
files.push_back(input);
|
||||
}
|
||||
|
||||
code_writer toassembly(files);
|
||||
toassembly.write_assembly();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user