void DirectoryScanner::scan(db::Watchfolder folder,std::string indir/*, std::string outdir, db::Preset preset, FileFilter & filter*/) {
   LOGDEBUG("Scanning Directory:" << indir);
   MyFileFilter filter=MyFileFilter(folder.extensionfilter);
   FileList list = File(indir).listFiles(filter);
   FileList::iterator it = list.begin();
   for (; it != list.end(); it++) {
     if ((*it)->isDirectory())
       scan(folder,(*it)->getPath());
     else
       computeFile(folder,*it->get());
   }
 }
Пример #2
0
bool GlueFile::WriteTable()
{
  AMJU_CALL_STACK;

  // Write the number of files.
  uint32 numFiles = m_table.size();
  numFiles = Endian(numFiles);
  m_gluefile.seekg(0);
  m_gluefile.write((char*)&numFiles, sizeof(uint32));

  // Write the new table position. 
  uint32 tablepos = Endian(m_tablePos);
  m_gluefile.write((char*)&tablepos, sizeof(uint32));
  
  // Seek to the table position
  m_gluefile.seekg(m_tablePos);

  // Iterate over sub-file list, writing to the GlueFile.
  for (FileList::iterator it = m_filenames.begin(); it != m_filenames.end(); ++it)
  {
    // Get the length of the sub-file name.
    uint32 subfilenamelen = it->length();
    uint32 endiansubfilenamelen = Endian(subfilenamelen);

#ifdef GLUE_FILE_DEBUG
std::cout << "GLUE FILE: Write table: writing size of name \"" << it->c_str() << "\": " << subfilenamelen << "\n";
#endif

    m_gluefile.write((char*)&endiansubfilenamelen, sizeof(uint32));

#ifdef GLUE_FILE_DEBUG
std::cout << "GLUE FILE: Write table: writing name \"" << it->c_str() << "\"\n";
#endif

    // Write the string
    m_gluefile.write(it->c_str(), subfilenamelen);

    // Write the size of this sub-file.
    uint32 size = m_table[*it].first;

#ifdef GLUE_FILE_DEBUG
std::cout << "GLUE FILE: Write table: writing size of file \"" << it->c_str() << "\": " << size << "\n";
#endif

    size = Endian(size);
    m_gluefile.write((char*)&size, sizeof(uint32));
  }

  return true;  
}
Пример #3
0
int App::run()
{
  // Initialize GUI interface
  if (isGui()) {
    PRINTF("GUI mode\n");

    // Setup the GUI screen
    jmouse_set_cursor(kArrowCursor);
    ui::Manager::getDefault()->invalidate();

    // Create the main window and show it.
    m_mainWindow.reset(new MainWindow);

    // Default status of the main window.
    app_rebuild_documents_tabs();
    app_default_statusbar_message();

    m_mainWindow->openWindow();

    // Redraw the whole screen.
    ui::Manager::getDefault()->invalidate();
  }

  // Set background mode for non-GUI modes
  set_display_switch_mode(SWITCH_BACKGROUND);

  // Procress options
  PRINTF("Processing options...\n");

  {
    Console console;
    for (FileList::iterator
           it  = m_files.begin(),
           end = m_files.end();
         it != end; ++it) {
      // Load the sprite
      Document* document = load_document(it->c_str());
      if (!document) {
        if (!isGui())
          console.printf("Error loading file \"%s\"\n", it->c_str());
      }
      else {
        // Mount and select the sprite
        UIContext* context = UIContext::instance();
        context->addDocument(document);

        if (isGui()) {
          // Recent file
          getRecentFiles()->addRecentFile(it->c_str());
        }
      }
    }
  }

  // Run the GUI
  if (isGui()) {
    // Support to drop files from Windows explorer
    install_drop_files();

#ifdef ENABLE_UPDATER
    // Launch the thread to check for updates.
    app::CheckUpdateThreadLauncher checkUpdate;
    checkUpdate.launch();
#endif

#ifdef ENABLE_WEBSERVER
    // Launch the webserver.
    app::WebServer webServer;
    webServer.start();
#endif

    // Run the GUI main message loop
    gui_run();

    // Uninstall support to drop files
    uninstall_drop_files();

    // Destroy all documents in the UIContext.
    const Documents& docs = m_modules->m_ui_context.getDocuments();
    while (!docs.empty())
      m_modules->m_ui_context.removeDocument(docs.back());

    // Destroy the window.
    m_mainWindow.reset(NULL);
  }
  // Start shell to execute scripts.
  else if (m_isShell) {
    m_systemConsole.prepareShell();

    if (m_modules->m_scriptingEngine.supportEval()) {
      Shell shell;
      shell.run(m_modules->m_scriptingEngine);
    }
    else {
      std::cerr << "Your version of " PACKAGE " wasn't compiled with shell support.\n";
    }
  }

  return 0;
}
Пример #4
0
int App::run()
{
  // Initialize GUI interface
  if (isGui()) {
    PRINTF("GUI mode\n");

    // Setup the GUI screen
    jmouse_set_cursor(kArrowCursor);
    ui::Manager::getDefault()->invalidate();

    // Create the main window and show it.
    m_mainWindow.reset(new MainWindow);

    // Default status of the main window.
    app_rebuild_documents_tabs();
    app_default_statusbar_message();

    m_mainWindow->openWindow();

    // Redraw the whole screen.
    ui::Manager::getDefault()->invalidate();

    // 2013-11-19 - JRM - Force setting active view to NULL, workaround for setting 
    // window title to proper devault value. (Issue #285)
    UIContext::instance()->setActiveView(NULL);
  }

  // Set background mode for non-GUI modes
  set_display_switch_mode(SWITCH_BACKGROUND);

  // Procress options
  PRINTF("Processing options...\n");

  {
    UIContext* context = UIContext::instance();
    Console console;
    for (FileList::iterator
           it  = m_files.begin(),
           end = m_files.end();
         it != end; ++it) {
      // Load the sprite
      Document* document = load_document(it->c_str());
      if (!document) {
        if (!isGui())
          console.printf("Error loading file \"%s\"\n", it->c_str());
      }
      else {
        // Mount and select the sprite
        context->addDocument(document);

        // Add the given file in the argument as a "recent file" only
        // if we are running in GUI mode. If the program is executed
        // in batch mode this is not desirable.
        if (isGui())
          getRecentFiles()->addRecentFile(it->c_str());

        // Add the document to the exporter.
        if (m_exporter != NULL)
          m_exporter->addDocument(document);
      }
    }
  }

  // Export
  if (m_exporter != NULL) {
    PRINTF("Exporting sheet...\n");

    m_exporter->exportSheet();
    m_exporter.reset(NULL);
  }

  // Run the GUI
  if (isGui()) {
#ifdef ENABLE_UPDATER
    // Launch the thread to check for updates.
    app::CheckUpdateThreadLauncher checkUpdate;
    checkUpdate.launch();
#endif

#ifdef ENABLE_WEBSERVER
    // Launch the webserver.
    app::WebServer webServer;
    webServer.start();
#endif

    // Run the GUI main message loop
    gui_run();

    // Destroy all documents in the UIContext.
    const Documents& docs = m_modules->m_ui_context.getDocuments();
    while (!docs.empty())
      m_modules->m_ui_context.removeDocument(docs.back());

    // Destroy the window.
    m_mainWindow.reset(NULL);
  }
  // Start shell to execute scripts.
  else if (m_isShell) {
    m_systemConsole.prepareShell();

    if (m_modules->m_scriptingEngine.supportEval()) {
      Shell shell;
      shell.run(m_modules->m_scriptingEngine);
    }
    else {
      std::cerr << "Your version of " PACKAGE " wasn't compiled with shell support.\n";
    }
  }

  return 0;
}