コード例 #1
0
ファイル: help.c プロジェクト: hyena/fuzzball
void
do_man(dbref player, char *topic, char *seg)
{
	if (show_subfile(player, MAN_DIR, topic, seg, FALSE))
		return;
	index_file(player, topic, MAN_FILE);
}
コード例 #2
0
ファイル: help.c プロジェクト: digitalcircuit/fuzzball
void
do_helpfile(dbref player, const char *dir, const char *file, char *topic, char *segment)
{
    if (show_subfile(player, dir, topic, segment, 0))
	return;
    index_file(player, topic, file);
}
コード例 #3
0
void Model_Report::outputReportFile(const wxString& str)
{
    wxFileOutputStream index_output(mmex::getReportIndex());
    wxTextOutputStream index_file(index_output);
    index_file << str;
    index_output.Close();
}
コード例 #4
0
ファイル: dfindex.cpp プロジェクト: maunsell/MWorks
void dfindex::load() {
	boost::filesystem::path index_file(this->indexFile());
	
	std::ifstream ifs(index_file.string().c_str(), std::ios::binary);
	boost::archive::text_iarchive ia(ifs);
	ia >> dfi;
}
コード例 #5
0
ファイル: dfindex.cpp プロジェクト: maunsell/MWorks
dfindex::dfindex(const boost::filesystem::path &data_file) : mwk_data_file(data_file) {
	if(!boost::filesystem::exists(mwk_data_file)) {
		std::cerr << ".mwk file: " << mwk_data_file.string() << " doesn't exist" << std::endl;
		throw new std::exception;
	}
	
	if(!boost::filesystem::is_directory(mwk_data_file)) {
		std::string temp_location_string(boost::archive::tmpdir() + mwk_data_file.leaf());
		boost::filesystem::path temp_location(temp_location_string, boost::filesystem::native);
		boost::filesystem::rename(mwk_data_file, temp_location);
		
		boost::filesystem::create_directory(mwk_data_file);
		boost::filesystem::rename(temp_location, mwk_data_file / mwk_data_file.leaf());
	}
	
	boost::filesystem::path actual_mwk_file(mwk_data_file / mwk_data_file.leaf());
	
	if(!boost::filesystem::exists(actual_mwk_file)) {
		std::cerr << ".mwk file: " << actual_mwk_file.string() << " doesn't exist" << std::endl;
		throw new std::exception;
	} else {			
		boost::filesystem::path index_file(this->indexFile());
		if(!boost::filesystem::exists(index_file)) {
			dfi = DataFileIndexer(actual_mwk_file, 5000, 4);	
			this->save();
		} 
		this->load();
	}
}
コード例 #6
0
ファイル: help.c プロジェクト: hyena/fuzzball
void
do_news(dbref player, char *topic, char *seg)
{
	if (show_subfile(player, NEWS_DIR, topic, seg, FALSE))
		return;
	index_file(player, topic, NEWS_FILE);
}
コード例 #7
0
ファイル: help.c プロジェクト: hyena/fuzzball
void
do_help(dbref player, char *topic, char *seg)
{
	if (show_subfile(player, HELP_DIR, topic, seg, FALSE))
		return;
	index_file(player, topic, HELP_FILE);
}
コード例 #8
0
ファイル: dfindex.cpp プロジェクト: maunsell/MWorks
void dfindex::save() const {
	boost::filesystem::path index_file(this->indexFile());
	
	std::ofstream ofs(index_file.string().c_str());
	
	boost::archive::text_oarchive oa(ofs);
	oa << dfi;
}
コード例 #9
0
ファイル: access.c プロジェクト: C3BI-pasteur-fr/golden
/* VL: keep db_name parameter for recursive calls when searching in virtual database indexes.
 * lst_notFound points to a memory area allocated by the caller to store adresses of result_t structures for which no match was found.
 * It is used and "free" by the caller.
 * For recursive calls to access_search and calls to index_search, use memory areas allocated by access_search.
 */
void access_search(WDBQueryData wData, char * db_name, int * nb_AC_not_found) {
  FILE *f;
  char *p, *file, buf[1024];
  int nb_AC_found;
#ifdef DEBUG
  result_t ** start_l=wData.start_l; // for printing debug info
#endif
  // cur_base may be virtual.
  /* Virtual database indexes */
  file = index_file(NULL, db_name, VIRSUF);
  //printf("Searching in file : %s \n",file);
  if (access(file, F_OK) != -1) {
    if ((f = fopen(file, "r")) == NULL) {
      error_fatal("memory", NULL); }

    while (fgets(buf, 1023, f) != NULL) {
      if ((p = strrchr(buf, '\n')) != NULL) { *p = '\0'; }
      access_search(wData, buf, nb_AC_not_found);
#ifdef DEBUG
      // dump list of accession numbers that were not found yet.
      print_wrk_struct(start_l,wData.len_l,1);
#endif
      if (*nb_AC_not_found!=0) {
#ifdef DEBUG
        printf("access_search : all results were not found ; continue \n");
#endif
        continue;
      }
      break;
    }
    if (fclose(f) == EOF) {
      error_fatal("memory", NULL); }
    free(file);
    return;  }

  /* Real database indexes */
  file = index_file(NULL, db_name, ACCSUF);
#ifdef DEBUG
  printf("Searching in file : %s \n",file);
#endif
    nb_AC_found=index_search(file, db_name, wData, nb_AC_not_found);
#ifdef DEBUG
  printf("access_search : returned from index_search DB : %s : nb_not_found_for_db=%d, nb_res_found=%d \n",db_name,*nb_AC_not_found,nb_AC_found);
#endif
  free(file);
  return;	}
コード例 #10
0
ファイル: indexer.cpp プロジェクト: Kazade/delimit
std::vector<ScopePtr> Indexer::index_file(const unicode &path) {
    /*
     *  Indexes a file by running a parser over it and storing the
     *  resulting scopes in the database
     */

    return index_file(path, read_file_contents(path));
}
コード例 #11
0
ファイル: access.c プロジェクト: C3BI-pasteur-fr/golden
int access_concat(char *dbase, uint64_t nb, indix_t *ind, char * new_index_dir) {
  int i=IDX_ERR;
  char *file;

  file = index_file(new_index_dir, dbase, ACCSUF);
  i = index_concat(file, nb, ind);
  free(file);
  return i;
}
コード例 #12
0
ファイル: access.c プロジェクト: C3BI-pasteur-fr/golden
/* Merge accession indexes */
int access_merge(char *dbase, uint64_t nb, indix_t *ind,char * new_index_dir) {
  int i;
  char *file;

  file = index_file(new_index_dir, dbase, ACCSUF);
  i = index_merge(file, nb, ind);
  free(file);

  return i; }
コード例 #13
0
ファイル: main.cpp プロジェクト: jfellus/pgcc_indexer
int main(int argc, char **argv) {
	if(argc<=2) USAGE();
	std::string out = argv[1];

	mkdir((const std::string&)argv[argc-1]);
	for(int i=1; i<argc-1; i++) index_file(argv[i], argv[argc-1]);

	return 0;
}
コード例 #14
0
void dfindex::load() {
	boost::filesystem::path index_file(this->indexFile());
	
	std::ifstream ifs(index_file.string().c_str(), std::ios::binary);
	boost::archive::text_iarchive ia(ifs);
	ia >> dfi;
    
    dfi.reconstituteScarabSession(mwk_data_file);
}
コード例 #15
0
void ReferenceIndex::save(const CL_StringRef &filename)
{
	CL_File index_file(filename, CL_File::create_always, CL_File::access_write);
	CL_String html =
		"<!-- clanlib header begin -->"
		"<HTML>"
		"<HEAD>"
		"<TITLE>Index - ClanLib Game SDK</TITLE>"
		"<STYLE TYPE=\"text/css\"><!--"
		"HTML BODY"
		"{"
		"        font-family: verdana, helvetica, sans-serif;"
		"        font-size: 12px;"
		"}"
		"H1 { font-size: 22px; }"
		"H2 { font-size: 18px; }"
		"H3 { font-size: 16px; }"
		"H4 { font-size: 14px; }"
		"P { font-size: 12px; }"
		"LI { font-size: 12px; }"
		".reflink:link { text-decoration: none; font-weight: bold; color: black; }"
		".reflink:visited { text-decoration: none; font-weight: bold; color: black; }"
		".reflink:active { text-decoration: none; font-weight: bold; color: black; }"
		".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }"
		"--></STYLE>"
		"</HEAD>"
		"<body bgcolor=white text=black link=blue vlink=#800080>"
		"<center>"
		"<img src=\"http://clanlib.org/gfx/clanlib.png\">"
		"</center>"
		"<!-- clanlib header end -->"
		"<center>"
		"<p>"
//		"<a href=\"http://clanlib.org/docs.html\">Home</a> |"
		"<a href=\"classes.html\">All Classes</a> |"
		"<a href=\"modules.html\">Grouped Classes</a> |"
		"<a href=\"index.html\">Index</a>"
//		"<a href=\"search.html\">Search</a>"
		"</p>"
		"</center>"
		"<h1>Index</h1>";
	index_file.write(html.data(), html.length());

	html =
		"<!-- clanlib footer begin -->"
//		"<center><br><br><font color=\"#a0a0a0\">"
//		"Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>."
//		"</font></center>"
		"<!-- clanlib footer end -->"
		"</body>"
		"</html>";
	index_file.write(html.data(), html.length());
}
コード例 #16
0
ファイル: indexer.c プロジェクト: jixuan90/209-Assignments
int main(int argc, char **argv) {

        Node *head = NULL;
        char **filenames = init_filenames();
        char ch;
        char *indexfile = "index";
        char *namefile = "filenames";
        char dirname[PATHLENGTH] = ".";
        char path[PATHLENGTH];

        while((ch = getopt(argc, argv, "i:n:d:")) != -1) {
                switch (ch) {
                        case 'i':
                        indexfile = optarg;
                        break;
                        case 'n':
                        namefile = optarg;
                        break;
                        case 'd':
                        strncpy(dirname, optarg, PATHLENGTH);
                        dirname[PATHLENGTH-1] = '\0'; 
                        break;
                        default:
                        fprintf(stderr, "Usage: indexer [-i FILE] [-n FILE ] [-d DIRECTORY_NAME]\n");
                        exit(1);
                }
        }
        DIR *dir;
        if((dir = opendir(dirname)) == NULL) {
                perror("opendir");
                exit(1);
        }
        struct dirent *dp;
        while((dp = readdir(dir)) != NULL) {
                if(strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 ||
                    strcmp(dp->d_name, ".svn") == 0) {
                        continue;
                }
                path[0] = '\0';
                strncpy(path, dirname, PATHLENGTH);
                strncat(path, "/", PATHLENGTH-strlen(path));
                strncat(path, dp->d_name, PATHLENGTH-strlen(path));
                path[PATHLENGTH-1] = '\0';
                printf("Indexing: %s\n", path);
                head = index_file(head, path, filenames);
        }
        write_list(namefile, indexfile, head, filenames);
        return 0;
}
コード例 #17
0
ファイル: indexer.cpp プロジェクト: Kazade/delimit
void Indexer::index_directory(const unicode &dir_path) {
    /*
     *  Recursively indexes the files in a directory
     */

    for(auto file: kfs::path::list_dir(dir_path.encode())) {
        auto full_path = kfs::path::join(dir_path.encode(), file);

        if(kfs::path::is_dir(full_path)) {
            index_directory(full_path);
        } else {
            index_file(full_path);
        }
    }
}
コード例 #18
0
ファイル: main.c プロジェクト: adrianob/word_search
int main(int argc, char *argv[]){
  //all input files must be in UTF-8!
  setlocale(LC_ALL,"");

  if(argc != 4){
    printf("entrada invalida, formato: entrada busca saida\n");
    return 0;
  }

  TREE_NODE *tree = index_file(argv[1]);

  search_words(tree, argv[2], argv[3]);

  return 0;
}
コード例 #19
0
bool Model_Report::outputReportFile(const wxString& str, const wxString& name)
{
    bool ok = true;
    wxFileOutputStream index_output(mmex::getReportFullName(name));
    if (index_output.IsOk())
    {
        wxTextOutputStream index_file(index_output);
        index_file << str;
        index_output.Close();
    }
    else
    {
        ok = false;
    }
    return ok;
}
コード例 #20
0
ファイル: treeview.c プロジェクト: llsf/mass
int main(int argc, char **argv){
    if(argc != 2) {
        printf("usage: %s [dir]\n", argv[0]);
        return 0;
    }
    if((out = fopen("tree.out", "w+")) == NULL)
    {
        perror("fopen:");
        exit(EXIT_FAILURE);
    }
    index_file(argv[1], levels);
    fclose(out);
    printf("\n\n");
    printf("\x1b[4;34;42m  files: %d \x1b[0m", files);
    printf("\x1b[4;35;43m  dirs: %d \x1b[0m", dirs);
    printf("\x1b[4;36;44m  levels: %d \x1b[0m\n", levels);

}
コード例 #21
0
ファイル: help.c プロジェクト: hyena/fuzzball
int
main(int argc, char**argv)
{
	char* helpfile = NULL;
	char* topic = NULL;
	char buf[BUFFER_LEN];
	if (argc < 2) {
			fprintf(stderr, "Usage: %s muf|mpi|help [topic]\n", argv[0]);
		exit(-1);
	} else if (argc == 2 || argc == 3) {
		if (argc == 2) {
			topic = "";
		} else {
			topic = argv[2];
		}
		if (!strcmp(argv[1], "man")) {
			helpfile = MAN_FILE;
		} else if (!strcmp(argv[1], "muf")) {
			helpfile = MAN_FILE;
		} else if (!strcmp(argv[1], "mpi")) {
			helpfile = MPI_FILE;
		} else if (!strcmp(argv[1], "help")) {
			helpfile = HELP_FILE;
		} else {
			fprintf(stderr, "Usage: %s muf|mpi|help [topic]\n", argv[0]);
			exit(-2);
		}

		helpfile = rindex(helpfile, '/');
		helpfile++;
#ifdef HELPFILE_DIR
		snprintf(buf, sizeof(buf), "%s/%s", HELPFILE_DIR, helpfile);
#else
		snprintf(buf, sizeof(buf), "%s/%s", "/usr/local/fbmuck/help", helpfile);
#endif

		index_file(1, topic, buf);
		exit(0);
	} else if (argc > 3) {
		fprintf(stderr, "Usage: %s muf|mpi|help [topic]\n", argv[0]);
		exit(-1);
	}
	return 0;
}
コード例 #22
0
ファイル: treeview.c プロジェクト: llsf/mass
int index_file(char* path, int level){
    DIR *dir;
    struct dirent *dirent;
    int i= 0;
    for(; i < level - 1; i++)
            printf("│  ");
    if(level > 0)
        printf("├──\x1b[0;31m%s\x1b[0m\n", strrchr(path, '/')+1);
    else
        printf("%s\n", path);
    fputs(path, out);
    fputc('\n', out);
    if(is_dir(path)){
        dirs++;
        if((dir = opendir(path)) == NULL){
            printf("cannot open dir!\n");
            exit(EXIT_FAILURE);
        }
        while((dirent = readdir(dir)) != NULL){ // && !(strcmp(".", dirent->d_name) || strcmp("..", dirent->d_name))){
            //printf("%d %s\n", strcmp("..", dirent->d_name), dirent->d_name);
            if(strcmp(".", dirent->d_name) && strcmp("..", dirent->d_name))
            {
            char *tmp = malloc(sizeof(char)*1024);
            memset(tmp, '0', 1024);
            strcpy(tmp, path);
            if(strcmp(tmp, ".") && strcmp(tmp, ".."))
                {
                if(strcmp("/\0", rindex(tmp, '/')))
                    strcat(tmp, "/");
                }
            else
                strcat(tmp, "/");
            strcat(tmp, dirent->d_name);
            index_file(tmp, level + 1);
            free(tmp);
            levels = level + 1;
            }
        }
    } else {
        files++;
        return level;
    }
    closedir(dir);
}
コード例 #23
0
ファイル: mmreportspanel.cpp プロジェクト: LjC/moneymanagerex
void mmReportsPanel::saveReportText()
{
    htmlreport_ = "coming soon..."; //TODO: ??
    if (rb_)
    {
        json::Object o;
        o[L"module"] = json::String(L"Report");
        o[L"name"] = json::String(rb_->title().ToStdWstring());
        o[L"start"] = json::String(wxDateTime::Now().FormatISOCombined().ToStdWstring());

        htmlreport_ = rb_->getHTMLText();

        wxFileOutputStream index_output(mmex::getReportIndex());
        wxTextOutputStream index_file(index_output);
        index_file << htmlreport_;
        index_output.Close();
        o[L"end"] = json::String(wxDateTime::Now().FormatISOCombined().ToStdWstring());
        Model_Usage::instance().append(o);
    }
}
コード例 #24
0
StaticServer::StaticServer( const RealmDescriptor& descriptor ) :
    _descriptor( descriptor ),
    _index(),
    _statics()
{
    BinaryFile index_file( _descriptor.path( "statidx.dat" ), ios::in );
    index_file.ReadVector( _index );
    if(_index.empty())
    {
        string message = "Empty file: " + _descriptor.path("statidx.dat");
        throw runtime_error( message );
    }

    BinaryFile statics_file( _descriptor.path( "statics.dat" ), ios::in );
    statics_file.ReadVector( _statics );
    if(_statics.empty())
    {
        string message = "Empty file: " + _descriptor.path("statics.dat");
        throw runtime_error( message );
    }

    Validate();
}
コード例 #25
0
ファイル: main.c プロジェクト: berkeley-cs186/course-fa07
/*-----
 *	The mother of all C functions
 *-----
 */
int
main(int argc, char **argv)
{
	LODumpMaster _pgLO,
			   *pgLO = &_pgLO;
	char	   *pwd = NULL;

	pgLO->argv = argv;
	pgLO->argc = argc;
	pgLO->action = 0;
	pgLO->lolist = NULL;
	pgLO->user = NULL;
	pgLO->db = NULL;
	pgLO->host = NULL;
	pgLO->port = NULL;
	pgLO->space = NULL;
	pgLO->index = NULL;
	pgLO->remove = FALSE;
	pgLO->quiet = FALSE;
	pgLO->counter = 0;
	pgLO->lolist_start = 0;

	progname = argv[0];

	/*
	 * Parse ARGV
	 */
	if (argc > 1)
	{
		int			arg;
		extern int	optind;
		int			l_index = 0;
		static struct option l_opt[] = {
			{"help", no_argument, 0, 'h'},
			{"user", required_argument, 0, 'u'},
			{"pwd", required_argument, 0, 'p'},
			{"db", required_argument, 0, 'd'},
			{"host", required_argument, 0, 'h'},
			{"port", required_argument, 0, 'o'},
			{"space", required_argument, 0, 's'},
			{"import", no_argument, 0, 'i'},
			{"export", no_argument, 0, 'e'},
			{"remove", no_argument, 0, 'r'},
			{"quiet", no_argument, 0, 'q'},
			{"all", no_argument, 0, 'a'},
			{"show", no_argument, 0, 'w'},
			{NULL, 0, 0, 0}
		};

		while ((arg = getopt_long(argc, argv, "?aeho:u:p:qd:l:t:irs:w", l_opt, &l_index)) != -1)
		{
			switch (arg)
			{
				case '?':
				case 'h':
					usage();
					exit(RE_OK);
				case 'u':
					pgLO->user = strdup(optarg);
					break;
				case 't':
					pgLO->host = strdup(optarg);
					break;
				case 'o':
					pgLO->port = strdup(optarg);
					break;
				case 'p':
					pwd = strdup(optarg);
					break;
				case 'd':
					pgLO->db = strdup(optarg);
					break;
				case 's':
					pgLO->space = strdup(optarg);
					break;
				case 'i':
					pgLO->action = ACTION_IMPORT;
					break;
				case 'l':
					pgLO->action = ACTION_EXPORT_ATTR;
					pgLO->lolist_start = optind - 1;
					parse_lolist(pgLO);
					break;
				case 'e':
				case 'a':
					pgLO->action = ACTION_EXPORT_ALL;
					break;
				case 'w':
					pgLO->action = ACTION_SHOW;
					break;
				case 'r':
					pgLO->remove = TRUE;
					break;
				case 'q':
					pgLO->quiet = TRUE;
					break;
				default:
					fprintf(stderr, "%s: bad arg -%c\n", progname, arg);
					usage();
					exit(RE_ERROR);
			}
		}
	}
	else
	{
		usage();
		exit(RE_ERROR);
	}

	/*
	 * Check space
	 */
	if (pgLO->space==NULL && pgLO->action != ACTION_SHOW)
	{
		if (!(pgLO->space = getenv("PWD")))
			pgLO->space = ".";
	}

	if (!pgLO->action)
	{
		fprintf(stderr, "%s: What do you want - export or import?\n", progname);
		exit(RE_ERROR);
	}

	/*
	 * Make connection
	 */
	pgLO->conn = PQsetdbLogin(pgLO->host, pgLO->port, NULL, NULL, pgLO->db,
							  pgLO->user, pwd);

	if (PQstatus(pgLO->conn) == CONNECTION_BAD)
	{
		fprintf(stderr, "%s (connection): %s\n", progname, PQerrorMessage(pgLO->conn));
		exit(RE_ERROR);
	}
	pgLO->host = PQhost(pgLO->conn) ? PQhost(pgLO->conn) : "localhost";
	pgLO->db = PQdb(pgLO->conn);
	pgLO->user = PQuser(pgLO->conn);


	/*
	 * Init index file
	 */
	if (pgLO->action != ACTION_SHOW)
		index_file(pgLO);

	PQexec(pgLO->conn, "SET search_path = public");

	PQexec(pgLO->conn, "BEGIN");

	switch (pgLO->action)
	{

		case ACTION_SHOW:
		case ACTION_EXPORT_ALL:
			load_lolist(pgLO);
			/* FALL THROUGH */

		case ACTION_EXPORT_ATTR:
			pglo_export(pgLO);
			if (!pgLO->quiet)
			{
				if (pgLO->action == ACTION_SHOW)
					printf("\nDatabase '%s' contains %d large objects.\n\n", pgLO->db, pgLO->counter);
				else
					printf("\nExported %d large objects.\n\n", pgLO->counter);
			}
			break;

		case ACTION_IMPORT:
			pglo_import(pgLO);
			if (!pgLO->quiet)
				printf("\nImported %d large objects.\n\n", pgLO->counter);
			break;
	}

	PQexec(pgLO->conn, "COMMIT");
	PQfinish(pgLO->conn);

	if (pgLO->action != ACTION_SHOW)
		fclose(pgLO->index);

	exit(RE_OK);
}
コード例 #26
0
TemplateCore::GenerationResult FlashCardCore::generateMobileApplication(const QString &input_apk_file, QString &output_file) {
  emit generationProgress(5, tr("Preparing workspace..."));

  qApp->templateManager()->generator()->cleanWorkspace();

  emit generationProgress(10, tr("Extracting raw data from editor..."));

  // We need data which will be imported into apk/zip file.
  QString quiz_data = editor()->generateBundleData();

  if (quiz_data.isEmpty()) {
    // No date received, this is big problem.
    return BundleProblem;
  }

  QString temp_folder = qApp->templateManager()->tempDirectory();
  QDir temp_directory(temp_folder);
  QString base_folder = temp_folder + "/" + APP_LOW_NAME;
  QDir base_directory(base_folder);

  // Preparation of target bundle file
  emit generationProgress(20, tr("Creating base temporary folder..."));

  temp_directory.mkdir(APP_LOW_NAME);
  base_directory.mkdir("assets");

  QFile index_file(base_folder + "/assets/flash_content.xml");
  index_file.open(QIODevice::WriteOnly | QIODevice::Text);

  emit generationProgress(30, tr("Writting info data into file..."));

  QTextStream out(&index_file);
  out << quiz_data;

  out.flush();
  index_file.close();

  emit generationProgress(40, tr("Copying template apk file..."));

  // Copying of target apk file.
  QString new_apk_name = input_apk_file;

  if (!QFile::copy(APP_TEMPLATES_PATH + "/" + entryPoint()->baseFolder() + "/" + entryPoint()->mobileApplicationApkFile(),
                   base_folder + "/" + new_apk_name)) {
    qApp->templateManager()->generator()->cleanWorkspace();
    return CopyProblem;
  }

  emit generationProgress(60, tr("Inserting data into apk file..."));

  // Inserting bundle file into apk file.
  QProcess zip;

  zip.setWorkingDirectory(base_folder);
  zip.start(qApp->zipUtilityPath(), QStringList() << "-m" << "-r" << new_apk_name << "assets");
  zip.waitForFinished();

  if (zip.exitCode() != EXIT_STATUS_ZIP_NORMAL) {
    // Error during inserting quiz data via zip.
    qApp->templateManager()->generator()->cleanWorkspace();
    return ZipProblem;
  }

  emit generationProgress(70, tr("Signing apk file..."));

  // Signing and renaming target file.
  QString pem_certificate = QDir::toNativeSeparators(APP_CERT_PATH + "/" + CERTIFICATE_PATH);
  QString pk_certificate = QDir::toNativeSeparators(APP_CERT_PATH + "/" + KEY_PATH);
  QProcess signapk;

  signapk.setWorkingDirectory(base_folder);
  signapk.start(qApp->javaInterpreterPath(), QStringList() << "-jar" << qApp->signApkUtlityPath() <<
                pem_certificate << pk_certificate << new_apk_name <<
                QDir::toNativeSeparators(new_apk_name + ".new"));
  signapk.waitForFinished();

  if (signapk.exitCode() != EXIT_STATUS_SIGNAPK_WORKING) {
    qApp->templateManager()->generator()->cleanWorkspace();
    return SignApkProblem;
  }

  emit generationProgress(90, tr("Copying final apk file to output directory..."));

  // Now, our file is created. We need to move it to target directory.
  if (!IOFactory::copyFile(base_folder + "/" + new_apk_name + ".new",
                           qApp->templateManager()->outputDirectory() + "/" + new_apk_name)) {
    qApp->templateManager()->generator()->cleanWorkspace();
    return CopyProblem;
  }

  output_file = QDir(qApp->templateManager()->outputDirectory()).filePath(new_apk_name);

  // Removing temporary files and exit.
  qApp->templateManager()->generator()->cleanWorkspace();
  return Success;
}
コード例 #27
0
ファイル: fastq_validator.c プロジェクト: hjanime/irap
int main(int argc, char **argv ) {
  //long paired=0;
  is_paired_data=0;
  is_interleaved=0;
  printf("Version iRAP %s\n",VERSION);
  if (argc<2 || argc>3) {
    fprintf(stderr,"Usage: fastq_validator fastq1 [fastq2 file|pe]\n");
    //fprintf(stderr,"%d",argc);
    exit(1);
  }

  FILE *fd1=NULL;
  FILE *fd2=NULL;
  // open & close
  fd1=open_fastq(argv[1]);
  fclose(fd1);
  //fprintf(stderr,"%d\n",argc);
  //bin/fprintf(stderr,"%s\n",argv[0]);
  if (argc ==3) {
    is_paired_data=1;
    if ( !strncmp(argv[2],"pe",2) ) {
      is_interleaved=1;
    } else  {
      fd2=open_fastq(argv[2]);
      fclose(fd2);
    }
  }
  // ************************************************************
  // casava 1.8?
  is_casava_18=is_casava_1_8(argv[1]);
  if (is_casava_18) fprintf(stderr,"CASAVA=1.8\n");
  // ************************************************************
  //off_t cur_offset=1;
  // interleaved
  if ( is_interleaved ) {
    exit(validate_interleaved(argv[1]));
  }
  unsigned long cline=1;
  fprintf(stderr,"HASHSIZE=%lu\n",(long unsigned int)HASHSIZE);
  //memset(&collisions[0],0,HASHSIZE+1);
  hashtable sn_index=new_hashtable(HASHSIZE);
  index_mem+=sizeof(hashtable);

  index_file(argv[1],sn_index,0,-1);
  fprintf(stderr,"\n");
  // print some info
  fprintf(stderr,"Reads processed: %ld\n",sn_index->n_entries);
  fprintf(stderr,"Memory used in indexing: ~%ld MB\n",index_mem/1024/1024);  
  // pair-end
  if (argc ==3 ) {
    fprintf(stderr,"File %s processed\n",argv[1]);  
    fprintf(stderr,"Next file %s\n",argv[2]);  
    // validate the second file and check if all reads are paired
    fd2=open_fastq(argv[2]);
    INDEX_ENTRY* e;
    // read the entry using another fd
    cline=1;
    // TODO: improve code - mostly duplicated:(
    while(!feof(fd2)) {
      //long start_pos=ftell(fd2);
      char *hdr=READ_LINE_HDR(fd2);
      if ( hdr==NULL) break;
      int len;
      char *seq=READ_LINE_SEQ(fd2);
      char *hdr2=READ_LINE_HDR2(fd2);
      char *qual=READ_LINE_QUAL(fd2);
      char* readname=get_readname(hdr,&len,cline,argv[2]);
      if (seq==NULL || hdr2==NULL || qual==NULL ) {
	fprintf(stderr,"Error in file %s, line %lu: file truncated?\n",argv[2],cline);
	exit(1);
      }
      if (validate_entry(hdr,hdr2,seq,qual,cline,argv[2])!=0) {
	exit(1);
      }
      //fprintf(stderr,"Reads processed: %ld\n",sn_index->n_entries);
      // check for duplicates
      if ( (e=lookup_header(sn_index,readname))==NULL ) {
	fprintf(stderr,"Error in file %s, line %lu: unpaired read - %s\n",argv[2],cline,readname);
	exit(1);
      } else {
	ulong key=hashit(readname);
	// remove entry from sn_index
	if (delete(sn_index,key,e)!=e) {
	  fprintf(stderr,"Error in file %s, line %lu: unable to delete entry from sn_index - %s\n",argv[2],cline,readname);
	  exit(1);
	}
	free_indexentry(e);
      }
      PRINT_READS_PROCESSED(cline/4);
      //
      cline+=4;
    }
    printf("\n");
    if (sn_index->n_entries>0 ) {
      fprintf(stderr,"Error in file %s: found %lu unpaired reads\n",argv[1],sn_index->n_entries);
      exit(1);
    }
  }
  printf("OK\n");  
  exit(0);
}
コード例 #28
0
ファイル: osmium_serdump.cpp プロジェクト: gijs/libosmium
int main(int argc, char* argv[]) {
    std::ios_base::sync_with_stdio(false);

    static struct option long_options[] = {
        {"help",      no_argument, 0, 'h'},
        {0, 0, 0, 0}
    };

    while (true) {
        int c = getopt_long(argc, argv, "h", long_options, 0);
        if (c == -1) {
            break;
        }

        switch (c) {
            case 'h':
                print_help();
                exit(0);
            default:
                exit(2);
        }
    }

    int remaining_args = argc - optind;

    if (remaining_args != 2) {
        std::cerr << "Usage: " << argv[0] << " OSMFILE DIR\n";
        exit(2);
    }

    std::string dir(argv[optind+1]);

    int result = ::mkdir(dir.c_str(), 0777);
    if (result == -1 && errno != EEXIST) {
        std::cerr << "Problem creating directory '" << dir << "': " << strerror(errno) << "\n";
        exit(2);
    }

    std::string data_file(dir + "/data.osm.ser");
    int data_fd = ::open(data_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
    if (data_fd < 0) {
        std::cerr << "Can't open data file '" << data_file << "': " << strerror(errno) << "\n";
        exit(2);
    }

    offset_index_type node_index;
    offset_index_type way_index;
    offset_index_type relation_index;

    osmium::handler::DiskStore disk_store_handler(data_fd, node_index, way_index, relation_index);

    map_type map_node2way;
    map_type map_node2relation;
    map_type map_way2relation;
    map_type map_relation2relation;

    osmium::handler::ObjectRelations object_relations_handler(map_node2way, map_node2relation, map_way2relation, map_relation2relation);

    osmium::io::Reader reader(argv[1]);
    osmium::io::Header header = reader.open();

    while (osmium::memory::Buffer buffer = reader.read()) {
        disk_store_handler(buffer);
        object_relations_handler(buffer);
    }

    {
        std::string index_file(dir + "/nodes.idx");
        int fd = ::open(index_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
        if (fd < 0) {
            std::cerr << "Can't open nodes index file '" << index_file << "': " << strerror(errno) << "\n";
            exit(2);
        }
        node_index.dump_as_list(fd);
        close(fd);
    }

    {
        std::string index_file(dir + "/ways.idx");
        int fd = ::open(index_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
        if (fd < 0) {
            std::cerr << "Can't open ways index file '" << index_file << "': " << strerror(errno) << "\n";
            exit(2);
        }
        way_index.dump_as_list(fd);
        close(fd);
    }

    {
        std::string index_file(dir + "/relations.idx");
        int fd = ::open(index_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
        if (fd < 0) {
            std::cerr << "Can't open relations index file '" << index_file << "': " << strerror(errno) << "\n";
            exit(2);
        }
        relation_index.dump_as_list(fd);
        close(fd);
    }

    {
        map_node2way.sort();
        std::string index_file(dir + "/node2way.map");
        int fd = ::open(index_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
        if (fd < 0) {
            std::cerr << "Can't open node->way map file '" << index_file << "': " << strerror(errno) << "\n";
            exit(2);
        }
        map_node2way.dump_as_list(fd);
        close(fd);
    }

    {
        map_node2relation.sort();
        std::string index_file(dir + "/node2rel.map");
        int fd = ::open(index_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
        if (fd < 0) {
            std::cerr << "Can't open node->rel map file '" << index_file << "': " << strerror(errno) << "\n";
            exit(2);
        }
        map_node2relation.dump_as_list(fd);
        close(fd);
    }

    {
        map_way2relation.sort();
        std::string index_file(dir + "/way2rel.map");
        int fd = ::open(index_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
        if (fd < 0) {
            std::cerr << "Can't open way->rel map file '" << index_file << "': " << strerror(errno) << "\n";
            exit(2);
        }
        map_way2relation.dump_as_list(fd);
        close(fd);
    }

    {
        map_relation2relation.sort();
        std::string index_file(dir + "/rel2rel.map");
        int fd = ::open(index_file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
        if (fd < 0) {
            std::cerr << "Can't open rel->rel map file '" << index_file << "': " << strerror(errno) << "\n";
            exit(2);
        }
        map_relation2relation.dump_as_list(fd);
        close(fd);
    }

    google::protobuf::ShutdownProtobufLibrary();
}
コード例 #29
0
int main(int argc, char **argv ) {
  long paired=0;

  //printf("%d",sizeof(struct index_entry)); 
  
  if (argc!=6) {
    fprintf(stderr,"Usage: fastqinterleaved2pair.c fastq fastq1 fastq2\n");
    //fprintf(stderr,"%d",argc);
    exit(1);
  }

  FILE *fd=open_fastq(argv[1]);
  // ************************************************************
  off_t cur_offset=1;
  unsigned long cline=1;
  hashtable index=new_hashtable(HASHSIZE);
  index_mem+=sizeof(hashtable);

  index_file(argv[1],index,0,-1);
  printf("\n");
  // print some info
  printf("Reads indexed: %ld\n",index->n_entries);
  printf("Memory used in indexing: %ld MB\n",index_mem/1024/1024);  
  // 

  char *p1=argv[3];
  char *p2=argv[4];
  char *p3=argv[5];
  fd1=open_fastq(argv[1]);
  fd2=open_fastq(argv[2]);
  FILE *fdw1=fopen(p1,"w");
  FILE *fdw2=fopen(p2,"w");
  FILE *fdw3=fopen(p3,"w");
  unsigned long up2=0;

  if ( fdw1==NULL || fdw2==NULL || fdw3==NULL ) {
    fprintf(stderr,"Unable to create output files\n");
    exit(1);
  }
  
  // read the entry using another fd
  cline=1;
  while(!feof(fd2)) {
    long start_pos=ftell(fd2);
    char *hdr=READ_LINE(fd2);

    if ( hdr==NULL) break;
    if ( hdr[0]!='@' ) {
      fprintf(stderr,"line %ul: error in header %s",cline,hdr);
      return 1;
    }
    // discard @ (one less byte)
    hdr=&hdr[1];
    int len=strlen(hdr);
    len--;
    hdr[len-1]='\0'; //
    // lookup hdr in index
    INDEX_ENTRY* e=lookup_header(index,hdr);
    if (e==NULL) {
      ++up2;
      copy_read(start_pos,fd2,fdw3);
    } else {
      long key=hashit(hdr);
      // pair found
      ++paired;
      copy_read(start_pos,fd2,fdw2);
      copy_read(e->entry_start,fd1,fdw1);
      // remove entry from index
      if (delete(index,key,e)!=e) {
	fprintf(stderr,"Unable to delete entry from index\n");
	exit(1);
      }
      free_indexentry(e);
    }
    PRINT_READS_PROCESSED(cline/4);

    cline+=4;
  }
  printf("\n");
  printf("Recording %ld unpaired reads from %s\n",index->n_entries,argv[1]);fflush(stdout);
  fclose(fd1);


  // record the unpaired from argv[1]
  fd1=open_fastq(argv[1]); 
#ifndef SEQDISKACCESS
  init_hash_traversal(index);
  INDEX_ENTRY* e;
  cline=1;
  while((e=(INDEX_ENTRY*)next_hash_object(index))!=NULL) {
          copy_read(e->entry_start,fd1,fdw3);
	  PRINT_READS_PROCESSED(cline);
	  ++cline;
  }
  //
#else
  //sequential disk access
  //
  cline=1;
  unsigned long remaining=index->n_entries;
  while(!feof(fd1) && remaining ) {
    //long start_pos=ftell(fd2);
    char *hdr=READ_LINE(fd1);

    if ( hdr==NULL) break;
    if ( hdr[0]!='@' ) {
      fprintf(stderr,"line %ld %s: error in header %s",cline,argv[1],hdr);
      return 1;
    }
    // discard @ (one less byte)
    hdr=&hdr[1];
    int len=strlen(hdr);
    len--;
    hdr[len-1]='\0'; //

    // lookup hdr in index
    INDEX_ENTRY* e=lookup_header(index,hdr);
    if (e!=NULL) {
      copy_read(e->entry_start,fd1,fdw3);
      remaining--;
    } else {
      READ_LINE(fd1);//seq
      READ_LINE(fd1);//qual
      READ_LINE(fd1);//qual
    }
    PRINT_READS_PROCESSED(cline/4);
    cline+=4;
  }
  fclose(fd1);
#endif
  printf("\n");
  printf("Unpaired from %s: %ld\n",argv[1],index->n_entries);
  printf("Unpaired from %s: %ld\n",argv[2],up2);
  printf("Paired: %ld\n",paired);
  /*fseek(fd2,start_pos,SEEK_SET);
    printf("%s",READ_LINE(fd2));
    printf("%s",READ_LINE(fd2));
    printf("%s",READ_LINE(fd2));
    printf("%s",READ_LINE(fd2));
  */
  fclose(fdw1);
  fclose(fdw2);
  fclose(fdw3);
  if ( paired == 0 ) {
    fprintf(stderr,"!!!WARNING!!! 0 paired reads! are the headers ok?\n");
    exit(1);
  }
  exit(0);
}
コード例 #30
0
void ImageWindow::slotData(KIO::Job* job, const QByteArray& file_contents)
{

	QDomDocument doc("Custom Deck");
        if (!doc.setContent(file_contents)) {
		KMessageBox::error(this, "Could not parse custom-deck.svg file", "ERROR");
        	return;
        }

	KUrl url = m_browser->url();
        QString path = url.path();
	if (path.isEmpty()){
		KMessageBox::error(this, "No image path selected.", "ERROR");
		return;
	}
	if (!QFile::exists(path)){
		KMessageBox::error(this, path + " is not a valid file path.", "ERROR");
		return;
	}
        QString name = m_browser->name(); //Put the name typed by the user into this varable
        QDomNodeList nodes = doc.elementsByTagName("image");
        QDomElement back;
        back = nodes.at(0).toElement();
        back.setAttribute("xlink:href", path);
        back.setAttribute("sodipodi:absref", path);

	QString deck_path = KStandardDirs::locateLocal( "data" , QString("carddecks/custom-") + name + "/", true);

	QFile index_file(deck_path + "index.desktop"); //Create a new index file for the custom deck.
	if (!index_file.open(QIODevice::WriteOnly | QFile::Truncate)){
		KMessageBox::error(this, QString("Could not open file ") + deck_path + "index.desktop for writing.", "ERROR");
		return;
	}
	

	QString image_base = QFileInfo(path).fileName();

	QTextStream out(&index_file);
	out << "[KDE Backdeck]" << endl;
	out << "Name=" << name << endl;
	out << "Preview=" << image_base << endl;
	out << "SVG=custom-deck.svgz" << endl;
	out << "Back=" << name << endl;
	out << "Author=decKreator Theming Tool" << endl;
	out << "[email protected]" << endl;
	out << "Comment=Theme based on Oxygen Air Theme by Eugene Trounev" << endl;
	out << "Comment=Created by decKreator" << endl;

	index_file.close();

	QFile preview_file(path);
	if (!preview_file.open(QIODevice::ReadOnly)){
		KMessageBox::error(this, QString("Could not open file ") + path, "ERROR");
		return;
	}

	preview_file.copy(deck_path + image_base);


	QString filename = deck_path + "custom-deck.svgz";	
	KFilterDev* zipfile = static_cast<KFilterDev*>(KFilterDev::deviceForFile(filename, "application/x-gzip"));
	if (!zipfile){
		KMessageBox::error(this, QString("Could not find compression filter"), "ERROR");
	}
	zipfile->setOrigFileName(filename.toLatin1());
	zipfile->open(QIODevice::WriteOnly);
	zipfile->write(doc.toString().toLatin1(), doc.toString().size()); 
	zipfile->close();
	KMessageBox::information(this, "Success!", "decKreator has successfully created a custom theme for your KPatience enjoyment.");
}