static void search_from_directory(DirectorySpecifier& BaseDir)
//	FSSpec *file)
{
    FileFinder pb;

    pb.Clear();
    pb.version= 0;
    // LP change: always recurse
    pb.flags= _ff_recurse | _ff_callback_with_catinfo;
#if 0
#ifdef FINAL
    pb.flags= _ff_recurse | _ff_callback_with_catinfo;
#else
    pb.flags= _ff_callback_with_catinfo;
#endif
#endif
    pb.search_type= _callback_only;
    pb.BaseDir = BaseDir;
    pb.Type= WILDCARD_TYPE;
    pb.buffer= NULL;
    pb.max= 32767; // maximum
    pb.callback= found_some_file_callback;
    pb.user_data= NULL;
    pb.count= 0;

    bool seek_ok= pb.Find();
    if(!seek_ok)
        vassert(seek_ok, csprintf(temporary, "Error: %d", pb.GetError()));
}
void AbstractCardiacMechanicsSolver<ELASTICITY_SOLVER,DIM>::SetVariableFibreSheetDirections(const FileFinder& rOrthoFile, bool definedPerQuadraturePoint)
{
    mFibreSheetDirectionsDefinedByQuadraturePoint = definedPerQuadraturePoint;

    FibreReader<DIM> reader(rOrthoFile, ORTHO);

    unsigned num_entries = reader.GetNumLinesOfData();

    if (!mFibreSheetDirectionsDefinedByQuadraturePoint && (num_entries!=this->mrQuadMesh.GetNumElements()) )
    {
        EXCEPTION("Number of entries defined at top of file " << rOrthoFile.GetAbsolutePath() <<
                  " does not match number of elements in the mesh, " << "found " <<  num_entries <<
                  ", expected " << this->mrQuadMesh.GetNumElements());
    }

    if (mFibreSheetDirectionsDefinedByQuadraturePoint && (num_entries!=mTotalQuadPoints) )
    {
        EXCEPTION("Number of entries defined at top of file " << rOrthoFile.GetAbsolutePath() <<
                  " does not match number of quadrature points defined, " << "found " <<  num_entries <<
                  ", expected " << mTotalQuadPoints);
    }

    mpVariableFibreSheetDirections = new std::vector<c_matrix<double,DIM,DIM> >(num_entries, zero_matrix<double>(DIM,DIM));
    for(unsigned index=0; index<num_entries; index++)
    {
        reader.GetFibreSheetAndNormalMatrix(index, (*mpVariableFibreSheetDirections)[index] );
    }
}
Exemplo n.º 3
0
FileFinder OutputFileHandler::CopyFileTo(const FileFinder& rSourceFile) const
{
    if (!rSourceFile.IsFile())
    {
        EXCEPTION("Can only copy single files:\n" << rSourceFile.GetAbsolutePath() << " is not a file.");
    }
    fs::path from_path(rSourceFile.GetAbsolutePath());
    fs::path to_path(GetOutputDirectoryFullPath());
    to_path /= from_path.leaf();
    if (PetscTools::AmMaster())
    {
        try
        {
            fs::copy_file(from_path, to_path);
        }
        // LCOV_EXCL_START
        catch (const fs::filesystem_error& e)
        {
            TERMINATE("Error copying file '" << rSourceFile.GetAbsolutePath() << "': " << e.what());
        }
        // LCOV_EXCL_STOP
    }
    PetscTools::Barrier("OutputFileHandler::CopyFileTo");
    return FileFinder(to_path.string(), RelativeTo::Absolute);
}
Exemplo n.º 4
0
int File::findChildren(FileFinder& finder, vector<File*>& results, bool recursive,
		bool archiveEntries) const
{
	int matchCount = 0;

	FileIterator* it = getIterator();
	File* child;

	while ((child = it->next())  !=  NULL) {
		bool matches = finder.matches(*child);
		if (matches) {
			results.push_back(child);
			matchCount++;
		}

		if (finder.isInterrupted()) {
			if (!matches) {
				delete child;
			}
			return matchCount;
		}

		if (recursive  &&  (child->isDirectory()  ||  (archiveEntries  &&  child->isArchiveFile()))) {
			matchCount += child->findChildren(finder, results, true, archiveEntries);
		}

		if (!matches) {
			delete child;
		}
	}

	delete it;
	return matchCount;
}
Exemplo n.º 5
0
 /**
  * Specify two files to compare, and open them for reading.
  * Actual comparison is done by calling CompareFiles.
  *
  * @param rFileFinder1  first file
  * @param rFileFinder2  second file
  * @param calledCollectively  If true there will be a barrier before opening files, and only master compares contents.
  * @param suppressOutput  If true then no errors will go to TS_TRACE(). Should only be set for the test of this class.
  */
 AbstractFileComparison(const FileFinder& rFileFinder1,
                        const FileFinder& rFileFinder2,
                        bool calledCollectively,
                        bool suppressOutput):
     mFilename1(rFileFinder1.GetAbsolutePath()),
     mFilename2(rFileFinder2.GetAbsolutePath()),
     mCalledCollectively(calledCollectively),
     mSuppressOutput(suppressOutput)
 {
     Setup();
 }
Exemplo n.º 6
0
static bool find_wad_file_with_checksum_in_directory(
  FileSpecifier& MatchingFile,
  DirectorySpecifier& BaseDir,
  Typecode file_type,
  uint32 checksum)
{
  bool success= false;
  FileFinder pb;
  struct find_checksum_private_data private_data;

  /* Setup the private data for the callback */
  private_data.checksum_to_match= checksum;

  /* Clear out the find_file pb */
  pb.Clear();

  /* Set the information */
  pb.version= 0;
  // LP change: always recurse
  pb.flags= _ff_recurse;       /* DANGER WILL ROBINSON!!! */
  pb.BaseDir = BaseDir;
  pb.Type= file_type;
  pb.buffer= &MatchingFile;
  pb.max= 1;       /* Only find one.. */
  pb.callback= match_wad_checksum_callback;
  pb.user_data= &private_data;

  /* Find them! */
  if (pb.Find()) {
    if(pb.count) {
      success= true;
    }
  }
  else {
    dprintf("Trying to find file, error: %d", pb.GetError());
  }

  return success;
}
Exemplo n.º 7
0
OutputFileHandler::OutputFileHandler(const FileFinder& rDirectory,
                                     bool cleanOutputDirectory)
{
    FileFinder output_root("", RelativeTo::ChasteTestOutput);
    std::string relative_path;
    try
    {
        relative_path = rDirectory.GetRelativePath(output_root);
    }
    catch (const Exception&)
    {
        EXCEPTION("The location provided to OutputFileHandler must be inside CHASTE_TEST_OUTPUT; '"
                  << rDirectory.GetAbsolutePath() << "' is not under '"
                  << output_root.GetAbsolutePath() << "'.");
    }
    if (*output_root.GetAbsolutePath().rbegin() != '/' && !relative_path.empty())
    {
        assert(*relative_path.begin() == '/');
        relative_path.erase(0, 1); // Remove leading slash
    }
    CommonConstructor(relative_path, cleanOutputDirectory);
}
Exemplo n.º 8
0
static bool find_file_with_modification_date_in_directory(
  FileSpecifier& MatchingFile,
  DirectorySpecifier& BaseDir,
  Typecode file_type,
  TimeType modification_date)
{
  bool success= false;
  FileFinder pb;

  /* Setup the private data for the callback */
  target_modification_date= modification_date;

  /* Clear out the find_file pb */
  pb.Clear();

  /* Set the information */
  pb.version= 0;
  // LP change: always recurse
  pb.flags= _ff_recurse | _ff_callback_with_catinfo;       /* DANGER WILL ROBINSON!!! */
  pb.BaseDir = BaseDir;
  pb.Type= file_type;
  pb.buffer= &MatchingFile;
  pb.max= 1;       /* Only find one.. */
  pb.callback= match_modification_date_callback;
  pb.user_data= NULL;

  /* Find them! */
  if (pb.Find()) {
    if(pb.count) {
      success= true;
    }
  }
  else {
    dprintf("Trying to find file, error: %d", pb.GetError());
  }

  return success;
}
Exemplo n.º 9
0
bool WinCore::ConnectExternalDevices()
{
	FileFinder ff;
	extern char m88dir[MAX_PATH];
	char buf[MAX_PATH];
	strncpy_s(buf, MAX_PATH, m88dir, _TRUNCATE);
	strncat_s(buf, MAX_PATH, "*.m88", _TRUNCATE);

	if (ff.FindFile(buf))
	{
		while (ff.FindNext())
		{
			const char* modname = ff.GetFileName();
			ExtendModule* em = ExtendModule::Create(modname, this);
			if (em)
			{
				extmodules.push_back(em);
			}
			else
			{
				ExternalDevice* extdevice = new ExternalDevice();
				if (extdevice)
				{
					if (extdevice->Init(modname, this, &bus1, GetDMAC(), &sound, &mm1))
					{
						devlist.Add(extdevice);
						extdevices.push_back(extdevice);
					}
					else
					{
						delete extdevice;
					}
				}
			}
		}
	}
	return true;
}
Exemplo n.º 10
0
FibreReader<DIM>::FibreReader(const FileFinder& rFileFinder, FibreFileType fibreFileType)
   : mFileIsBinary(false), // overwritten by ReadNumLinesOfDataFromFile() if applicable.
     mNextIndex(0u)
{
    if (fibreFileType == AXISYM)
    {
        mNumItemsPerLine = DIM;
    }
    else //(fibreFileType == ORTHO)
    {
        mNumItemsPerLine = DIM*DIM;
    }
    mTokens.resize(mNumItemsPerLine);

    mFilePath = rFileFinder.GetAbsolutePath();
    mDataFile.open(mFilePath.c_str());
    if (!mDataFile.is_open())
    {
        EXCEPTION("Failed to open fibre file " + rFileFinder.GetAbsolutePath());
    }

    // Note: this method will close the file on error
    ReadNumLinesOfDataFromFile();
}
Exemplo n.º 11
0
void AbstractHdf5Converter<ELEMENT_DIM,SPACE_DIM>::GenerateListOfDatasets(const FileFinder& rH5Folder,
                                                                          const std::string& rFileName)
{
    /*
     * Open file.
     */
    std::string file_name = rH5Folder.GetAbsolutePath() + rFileName + ".h5";
    hid_t file = H5Fopen(file_name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);

    /*
     * Begin HDF5 iteration, calls a method that populates mDatasetNames.
     */
#if H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >=8
    //std::cout << "HDF5 1.8.x or above detected.\n";
    H5Literate(file, H5_INDEX_NAME, H5_ITER_NATIVE, NULL, op_func, &mDatasetNames);
#else
    //std::cout << "HDF5 1.6.x  detected.\n";
    H5Giterate(file, "/", NULL, op_func, &mDatasetNames);
#endif

    H5Fclose(file);

    // Remove datasets that end in "_Unlimited", as these are paired up with other ones!
    std::string ending = "_Unlimited";

    // Strip off the independent variables from the list
    std::vector<std::string>::iterator iter;
    for (iter = mDatasetNames.begin(); iter != mDatasetNames.end(); )
    {
        // If the dataset name is "Time" OR ...
        // it is longer than the ending we are looking for ("_Unlimited") ...
        // ... AND it ends with the string we are looking for,
        // then erase it.
        if ( (*(iter) == "Time") ||
             ( ( iter->length() > ending.length() ) &&
               ( 0 == iter->compare(iter->length() - ending.length(), ending.length(), ending) ) ) )
        {
            iter = mDatasetNames.erase(iter);
        }
        else
        {
            ++iter;
        }
    }
}
Exemplo n.º 12
0
static int handle_arg(const char *arg, FileFinder &finder)
{
  struct stat sb;

  int ret = stat(arg, &sb);
  if (ret) {
    perror("stat");
    return ret;
  }

  std::string str_arg(arg);

  switch (sb.st_mode & S_IFMT) {
  case S_IFDIR:
    ret = finder.find_files(str_arg);
    break;

  default:
    fprintf(stderr, "Only directories are supported\n");
    ret = -1;
  }

  return ret;
}
Exemplo n.º 13
0
    void TestWeCanOnlyDeleteFoldersWeHaveMadeOurselves() throw(Exception, std::exception)
    {
        std::string test_folder = "cannot_delete_me";
        if (PetscTools::AmMaster())
        {
            ABORT_IF_THROWS(fs::create_directories(OutputFileHandler::GetChasteTestOutputDirectory() + test_folder));
        }
        // Wait until directory has been created, and check it exists
        PetscTools::Barrier("TestWeCanOnlyDeleteFoldersWeHaveMadeOurselves-1");
        FileFinder cannot_delete(test_folder, RelativeTo::ChasteTestOutput);
        TS_ASSERT(cannot_delete.IsDir());

        // Try to use it as an output folder
        TS_ASSERT_THROWS_CONTAINS(OutputFileHandler bad_handler(test_folder),
                                  "because signature file \".chaste_deletable_folder\" is not present");

        // Tidy up
        if (PetscTools::AmMaster())
        {
            TS_ASSERT(cannot_delete.Exists());
            cannot_delete.DangerousRemove();
            TS_ASSERT(!cannot_delete.Exists());
        }

        // Now create a folder the proper way
        test_folder = "can_delete_me";
        OutputFileHandler handler(test_folder);
        out_stream p_file_stream = handler.OpenOutputFile("test_file");
        p_file_stream->close(); // Windows does not like deleting open files

        // Test file is present
        FileFinder test_file = handler.FindFile("test_file");
        TS_ASSERT(test_file.Exists());
        PetscTools::Barrier("TestWeCanOnlyDeleteFoldersWeHaveMadeOurselves-2");

        OutputFileHandler handler2(test_folder, false /* don't clean */);

        // Test file is still present
        TS_ASSERT(test_file.Exists());
        PetscTools::Barrier("TestWeCanOnlyDeleteFoldersWeHaveMadeOurselves-3");

        OutputFileHandler handler3(test_folder, true /* do clean */);

        // Test file is deleted
        TS_ASSERT(!test_file.Exists());
        PetscTools::Barrier("TestWeCanOnlyDeleteFoldersWeHaveMadeOurselves-4");

        // Check we can delete the test_folder too
        if (PetscTools::AmMaster())
        {
            FileFinder folder = handler.FindFile("");
            TS_ASSERT(folder.Exists());
            folder.Remove();
            TS_ASSERT(!folder.Exists());
        }

        // Test we can make a directory of folders and delete them all
        OutputFileHandler handler4("what_about_me/and_me/and_me/and_da_da_da", true);

        // Check we have made a subdirectory
        FileFinder sub_folder("what_about_me/and_me", RelativeTo::ChasteTestOutput);
        TS_ASSERT(sub_folder.IsDir());
        PetscTools::Barrier("TestWeCanOnlyDeleteFoldersWeHaveMadeOurselves-5");

        OutputFileHandler handler5("what_about_me", true);

        // Check we have wiped the sub-directories
        TS_ASSERT(!sub_folder.Exists());
        PetscTools::Barrier("TestWeCanOnlyDeleteFoldersWeHaveMadeOurselves-6");

        // Check we can delete the main directory too
        if (PetscTools::AmMaster())
        {
            FileFinder folder = handler5.FindFile("");
            TS_ASSERT(folder.Exists());
            folder.Remove();
            TS_ASSERT(!folder.Exists());
        }
    }
Exemplo n.º 14
0
int main(int argc, char *argv[])
{
  if (argc == 1) {
    usage(argv[0]);
    return EXIT_FAILURE;
  }

  std::string szInputFolder;
  int index;
  bool bDryRun = false;

  for (index = 1; index < argc && argv[index][0] == '-'; index++) {
    std::string option(&argv[index][1]);

    if (option == "h" || option == "-help") {
      usage(argv[0]);
      return EXIT_SUCCESS;
    } else if (option == "d" || option == "-dry-run") {
      bDryRun = true;
    } else if (option == "i" || option == "-input") {
      if (index + 1 < argc) {
        szInputFolder = argv[++index];
        struct stat sb;
        int ret = stat(szInputFolder.c_str(), &sb);
        if (ret) {
          perror("stat");
          return EXIT_FAILURE;
        }

        if (!S_ISDIR(sb.st_mode)) {
          fprintf(stderr, "Input directory not a directory\n");
          return EXIT_FAILURE;
        }

      } else {
        fprintf(stderr, "Error: Missing directory name\n");
        return EXIT_FAILURE;
      }
    } else {
      fprintf(stderr, "Error: Unknown option \"-%s\"\n", option.c_str());
      usage(argv[0]);
      return EXIT_FAILURE;
    }
  }

  if (index == argc) {
    fprintf(stderr, "Error: No directory specified\n");
    return EXIT_FAILURE;
  }

  if (index + 1 != argc) {
    fprintf(stderr, "Error: More than one directory specified\n");
    return EXIT_FAILURE;
  }

  FileFinder oFiles;

  int rc = handle_arg(argv[index], oFiles);
  if (rc)
    return EXIT_FAILURE;

  if (szInputFolder.empty())
    szInputFolder = argv[index];

  const std::vector<RawWorkItem *> o_WorkItems = oFiles.get_work_items();
  if (o_WorkItems.size() == 0) {
    printf("No raw files found in folder '%s'\n", argv[index]);
    return EXIT_SUCCESS;
  }

  std::list<std::string> filter;
  filter.push_back(dng_suffix);

  std::list<std::string> files;
  rc = list_dir(szInputFolder, files, filter);
  if (rc)
    return EXIT_FAILURE;

  if (files.size() == 0) {
    printf("No DNG files found in folder '%s'\n", szInputFolder.c_str());
    return EXIT_SUCCESS;
  }

  rc = do_prune(o_WorkItems, files, bDryRun);
  if (rc)
    return EXIT_FAILURE;

  printf("Prune complete\n");

  return EXIT_SUCCESS;
}
    void TestNodeBasedSimulationWithContactInhibition()
    {
        EXIT_IF_PARALLEL;    // HoneycombMeshGenerator does not work in parallel

        // Create a simple 2D NodeBasedCellPopulation
        HoneycombMeshGenerator generator(5, 5, 0);
        TetrahedralMesh<2,2>* p_generating_mesh = generator.GetMesh();
        NodesOnlyMesh<2> mesh;
        mesh.ConstructNodesWithoutMesh(*p_generating_mesh, 1.5);

        MAKE_PTR(WildTypeCellMutationState, p_state);
        MAKE_PTR(TransitCellProliferativeType, p_transit_type);
        std::vector<CellPtr> cells;
        for (unsigned i=0; i<mesh.GetNumNodes(); i++)
        {
            ContactInhibitionCellCycleModel* p_cycle_model = new ContactInhibitionCellCycleModel();
            p_cycle_model->SetDimension(2);
            p_cycle_model->SetBirthTime(-10.0);
            p_cycle_model->SetQuiescentVolumeFraction(0.9);
            p_cycle_model->SetEquilibriumVolume(0.7854); //pi *(0.5)^2
            p_cycle_model->SetStemCellG1Duration(0.1);
            p_cycle_model->SetTransitCellG1Duration(0.1);

            CellPtr p_cell(new Cell(p_state, p_cycle_model));
            p_cell->SetCellProliferativeType(p_transit_type);
            cells.push_back(p_cell);
        }

        NodeBasedCellPopulation<2> cell_population(mesh, cells);
        cell_population.AddPopulationWriter<CellMutationStatesCountWriter>();
        cell_population.AddCellWriter<CellVolumesWriter>();
        cell_population.AddPopulationWriter<NodeVelocityWriter>();

        // Create a simulation
        OffLatticeSimulation<2> simulator(cell_population);
        simulator.SetOutputDirectory("TestNodeBasedSimulationWithVolumeTracked");

        TS_ASSERT_EQUALS(simulator.GetDt(), 1.0/120.0); // Default value for off-lattice simulations
        simulator.SetEndTime(simulator.GetDt()/2.0);

        // Create a volume-tracking modifier and pass it to the simulation
        MAKE_PTR(VolumeTrackingModifier<2>, p_modifier);
        simulator.AddSimulationModifier(p_modifier);

        // Create a force law and pass it to the simulation
        MAKE_PTR(GeneralisedLinearSpringForce<2>, p_force);
        p_force->SetCutOffLength(1.5);
        simulator.AddForce(p_force);

        // Run simulation
        simulator.Solve();

        // Test that the node velocities file exists
        OutputFileHandler output_file_handler("TestNodeBasedSimulationWithVolumeTracked", false);
        FileFinder generated = output_file_handler.FindFile("results_from_time_0/nodevelocities.dat");
        TS_ASSERT(generated.Exists());

        // Test that the volumes of the cells are correct in CellData at the first timestep
        for (AbstractCellPopulation<2>::Iterator cell_iter = cell_population.Begin();
             cell_iter != cell_population.End();
             ++cell_iter)
        {
            TS_ASSERT_DELTA(cell_population.GetVolumeOfCell(*cell_iter), cell_iter->GetCellData()->GetItem("volume"), 1e-4);
        }

        simulator.SetEndTime(2.0);

        // Run simulation
        simulator.Solve();

        // Test that the volumes of the cells are correct in CellData at the end time
        for (AbstractCellPopulation<2>::Iterator cell_iter = cell_population.Begin();
             cell_iter != cell_population.End();
             ++cell_iter)
        {
            TS_ASSERT_DELTA(cell_population.GetVolumeOfCell(*cell_iter), cell_iter->GetCellData()->GetItem("volume"), 1e-4);
        }

        // Check that the correct number of cells are labelled (i.e. experiencing contact inhibition)
        TS_ASSERT_EQUALS(cell_population.GetCellPropertyRegistry()->Get<CellLabel>()->GetCellCount(), 2u);
    }
DynamicCellModelLoaderPtr CellMLToSharedLibraryConverter::Convert(const FileFinder& rFilePath,
                                                                  bool isCollective)
{
    DynamicCellModelLoaderPtr p_loader;
    std::string absolute_path = rFilePath.GetAbsolutePath();
    // Find out whether rFilePath is a .cellml or .so
    size_t dot_position = absolute_path.find_last_of(".");
    if (dot_position == std::string::npos)
    {
        EXCEPTION("File does not have an extension: " + absolute_path);
    }
    std::string extension = absolute_path.substr(dot_position+1);
    // We make a modifiable version of the const FileFinder just incase we feel like
    // amending the suffix
    FileFinder file_path_copy(rFilePath);
#ifdef __APPLE__
    if (extension == "so")
    {
        WARN_ONCE_ONLY("CellMLToSharedLibraryConverter asked to load a \".so\" file.  On this architecture it should be \".dylib\"");
        extension = "dylib";
        absolute_path.replace(dot_position+1, 5, extension);
        file_path_copy.SetPath(absolute_path,  RelativeTo::Absolute);
    }
#endif
    // Check the file exists
    if (!file_path_copy.Exists())
    {
        EXCEPTION("Dynamically loadable cell model '" + absolute_path + "' does not exist.");
    }
    if (extension == "cellml")
    {
        // Split the path into folder and leaf
        size_t slash_position = absolute_path.find_last_of("/\\");
        assert(slash_position != std::string::npos);
        std::string folder = absolute_path.substr(0, slash_position+1); // Include trailing slash
        std::string leaf = absolute_path.substr(slash_position+1, dot_position-slash_position); // Include dot
        std::string so_path = folder + "lib" + leaf + msSoSuffix;
        // Does the .so file already exist (and was it modified after the .cellml?)
        FileFinder so_file(so_path, RelativeTo::Absolute);
        if (!so_file.Exists() || rFilePath.IsNewerThan(so_file))
        {
            if (!isCollective)
            {
                EXCEPTION("Unable to convert .cellml to .so unless called collectively, due to possible race conditions.");
            }
            ConvertCellmlToSo(absolute_path, folder);
        }
        // Load the .so
        p_loader = DynamicModelLoaderRegistry::Instance()->GetLoader(so_file);
    }
    else if (extension == msSoSuffix)
    {
        // Just load the .so
        // Note that this may have been modified to .dylib
        p_loader = DynamicModelLoaderRegistry::Instance()->GetLoader(file_path_copy);
    }
    else
    {
        EXCEPTION("Unsupported extension '." + extension + "' of file '" + absolute_path + "'; must be .so, .dylib or .cellml");
    }

    return p_loader;
}
Exemplo n.º 17
0
DynamicCellModelLoaderPtr DynamicModelLoaderRegistry::GetLoader(const FileFinder& rFileFinder)
{
    return GetLoader(rFileFinder.GetAbsolutePath());
}
Exemplo n.º 18
0
int main(int argc, char* argv[])
{
	std::string sourceDirectory = "/home/judge/submission-q/";;
	std::string destDirectory = "/home/judge/submission-results/";
	std::string exCheckDirectory = "/home/judge/exercise-checks/";
	std::string exInputDirectory = "/home/judge/exercise-input/";
	std::string permanentSaveDirectory = "/home/judge/submission-vault/";
	size_t sleepTime = 2;

	// check for arguments
	for(int i = 1; i < argc; ++i)
	{
		// specifies a directory to check for files
		if (std::string(argv[i]) == "-s" || std::string(argv[i]) == "--source" )
		{
			sourceDirectory = std::string(argv[i+1]);
			++i;
		}
		else if (std::string(argv[i]) == "-d" || std::string(argv[i]) == "--dest" )
		{
			destDirectory = std::string(argv[i+1]);
			++i;
		}
		else if (std::string(argv[i]) == "-e" || std::string(argv[i]) == "--exercise")
		{
			exCheckDirectory = std::string(argv[i+1]);
			++i;
		}
		else if (std::string(argv[i]) == "-i" || std::string(argv[i]) == "--input")
		{
			exInputDirectory = std::string(argv[i+1]);
			++i;
		}
		else if (std::string(argv[i]) == "-p" || std::string(argv[i]) == "--permanent")
		{
			permanentSaveDirectory = std::string(argv[i+1]);
			++i;
		}
		else if (std::string(argv[i]) == "-t" || std::string(argv[i]) == "--timer" )
		{
			sleepTime = atoi(argv[i+1]);
			++i;
		}
		else if (std::string(argv[i]) == "-h" || std::string(argv[i]) == "--help" )
		{
			std::cout << "This program checks for new submissions in a specified or default\n";
			std::cout << "directory, then compiles, error checks, saves results, and removes\n";
			std::cout << "original files\nArguments:\n";
			std::cout << "-s <directory> --source <directory> specified source directory to search\n";
			std::cout << "-d <directory> --dest <directory> specified directory to save results\n";
			std::cout << "-e <directory> --exercise <directory> specified directory where exercise checks are\n";
			std::cout << "-i <directory> --input <directory> specified directory where exercise input files are\n";
			std::cout << "-p <directory> --permanent <directory> directory where permanent submissions are stored\n";
			std::cout << "-t <time in integer> --timer <time in integer> amount to sleep between checks\n";
			std::cout << "-h --help display this help dialog\n";
			return 0;
		}
		else
		{
			std::cout << "Argument not found. Use -h for help on arguments\n";
			return 1;
		}
	}
	
	std::cout << "SETUP CONFIG\n";
	std::cout << "Source directory: " << sourceDirectory;
	std::cout << "\nDestination directory: " << destDirectory;
	std::cout << "\nExercise Check directory: " << exCheckDirectory;
	std::cout << "\nExercise Input directory: " << exInputDirectory;
	std::cout << "\nPermanent Storage location: " << permanentSaveDirectory;
	std::cout << "\nSleep time between folder check: " << sleepTime << "\n";

	// setup the file finder
	FileFinder finder;
	finder.setDirectories(sourceDirectory, destDirectory);

	// dummy variable, should never false unless server crashes
	bool serverOnline = true;
	while(serverOnline)
	{
		// check for new content. if so, start running the files through file handler
		if (finder.isNewContent())
		{
			std::cout << "Found new content, working...";
			std::vector<std::string> filesToCompile = finder.getFiles();
			FileHandler handler(sourceDirectory, destDirectory, exCheckDirectory, exInputDirectory, permanentSaveDirectory);
			handler.addFiles(filesToCompile);
			handler.run();
			std::cout << "Completed\n";
		}

		sleep(sleepTime);
	}

	return 0;
}