Example #1
0
result_t compress_directory(struct pak_file* pak, struct paki_args* args, const char* subdir)
{
    result_t r;
    char directory[DH_PATH_MAX];
    char filepath[DH_PATH_MAX];
    char fullfilepath[DH_PATH_MAX];

    strcpy(directory, args->path);
    if (subdir[0] != 0)     {
        path_join(directory, directory, subdir, NULL);
    }

    WIN32_FIND_DATA fdata;
    char filter[DH_PATH_MAX];
    path_join(filter, directory, "*", NULL);
    HANDLE find_hdl = FindFirstFile(filter, &fdata);
    if (find_hdl == INVALID_HANDLE_VALUE)    {
        printf(TERM_BOLDRED "Creating pak failed: directory '%s' does not exist.\n" TERM_RESET,
               directory);
        return RET_FAIL;
    }

    /* read directory recuresively, and compress files into pak */
    BOOL fr = TRUE;
    while (fr)     {
        if (!str_isequal(fdata.cFileName, ".") && !str_isequal(fdata.cFileName, ".."))    {
            filepath[0] = 0;
            if (subdir[0] != 0)     {
                strcpy(filepath, subdir);
            }

            if (!BIT_CHECK(fdata.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY))  {
                /* put the file into the archive */
                path_join(filepath, filepath, fdata.cFileName, NULL);
                path_join(fullfilepath, directory, fdata.cFileName, NULL);

                r = archive_put(pak, args, fullfilepath, filepath);
                if (IS_OK(r) && BIT_CHECK(args->usage, PAKI_USAGE_VERBOSE))     {
                    puts(filepath);
                }   else if (IS_FAIL(r))  {
                    err_sendtolog(FALSE);
                    args->err_cnt ++;
                }
                args->file_cnt ++;
            }   else    {
                /* it's a directory, recurse */
                path_join(filepath, filepath, fdata.cFileName, NULL);
                compress_directory(pak, args, filepath);
            }
        }
        fr = FindNextFile(find_hdl, &fdata);
    }

    FindClose(find_hdl);
    return RET_OK;
}
Example #2
0
string path_cache_get(const string& sub)
{
#if defined(__linux__) || defined(__APPLE__)
	if(cached_xdg_cache_path == "") {
		cached_xdg_cache_path = path_xdg_cache_get();
	}
	string result = path_join(cached_xdg_cache_path, "cycles");
	return path_join(result, sub);
#else
	/* TODO(sergey): What that should be on Windows? */
	return path_user_get(path_join("cache", sub));
#endif
}
Example #3
0
result_t compress_directory(struct pak_file* pak, struct paki_args* args, const char* subdir)
{
    result_t r;
    char directory[DH_PATH_MAX];
    char filepath[DH_PATH_MAX];
    char fullfilepath[DH_PATH_MAX];

    strcpy(directory, args->path);
    if (subdir[0] != 0)     {
        path_join(directory, path_norm(directory, directory), subdir, NULL);
    }

    DIR* dir = opendir(directory);
    if (dir == NULL)    {
        printf(TERM_BOLDRED "Creating pak failed: directory '%s' does not exist.\n" TERM_RESET,
               directory);
        return RET_FAIL;
    }

    /* read directory recuresively, and compress files into pak */
    struct dirent* ent = readdir(dir);
    while (ent != NULL)     {
        if (!str_isequal(ent->d_name, ".") && !str_isequal(ent->d_name, ".."))    {
            filepath[0] = 0;
            if (subdir[0] != 0)
                strcpy(filepath, subdir);

            if (ent->d_type != DT_DIR)  {
                // put the file into the archive
                path_join(filepath, filepath, ent->d_name, NULL);
                path_join(fullfilepath, directory, ent->d_name, NULL);
                r = archive_put(pak, args, fullfilepath, filepath);
                if (IS_OK(r) && BIT_CHECK(args->usage, PAKI_USAGE_VERBOSE))     {
                    puts(filepath);
                }   else if (IS_FAIL(r))  {
                    err_sendtolog(FALSE);
                    args->err_cnt ++;
                }
                args->file_cnt ++;
            }   else    {
                // it's a directory, recurse
                path_join(filepath, filepath, ent->d_name, NULL);
                compress_directory(pak, args, filepath);
            }
        }
        ent = readdir(dir);
    }

    closedir(dir);
    return RET_OK;
}
Example #4
0
File: cuew.c Project: pawkoz/dyplom
const char *cuewCompilerPath(void) {
#ifdef _WIN32
  const char *defaultpaths[] = {"C:/CUDA/bin", NULL};
  const char *executable = "nvcc.exe";
#else
  const char *defaultpaths[] = {
    "/Developer/NVIDIA/CUDA-5.0/bin",
    "/usr/local/cuda-5.0/bin",
    "/usr/local/cuda/bin",
    "/Developer/NVIDIA/CUDA-6.0/bin",
    "/usr/local/cuda-6.0/bin",
    "/Developer/NVIDIA/CUDA-5.5/bin",
    "/usr/local/cuda-5.5/bin",
    NULL};
  const char *executable = "nvcc";
#endif
  int i;

  const char *binpath = getenv("CUDA_BIN_PATH");

  static char nvcc[65536];

  if (binpath) {
    path_join(binpath, executable, sizeof(nvcc), nvcc);
    if (path_exists(nvcc))
      return nvcc;
  }

  for (i = 0; defaultpaths[i]; ++i) {
    path_join(defaultpaths[i], executable, sizeof(nvcc), nvcc);
    if (path_exists(nvcc))
      return nvcc;
  }

#ifndef _WIN32
  {
    FILE *handle = popen("which nvcc", "r");
    if (handle) {
      char buffer[4096] = {0};
      int len = fread(buffer, 1, sizeof(buffer) - 1, handle);
      buffer[len] = '\0';
      pclose(handle);

      if (buffer[0])
        return "nvcc";
    }
  }
#endif

  return NULL;
}
Example #5
0
/* still needs freeing! */
static char* construct_path(vaht_resource* res, char* out, const char* ext)
{
    const char* origname = vaht_resource_name(res);
    char* name = NULL;
    if (strlen(origname) > 0)
        name = make_path_safe(origname);

    uint32_t name_len = 0;
    if (name)
    {
        name_len = strlen(name);
    }
    
    /* 11 = 4 + 1 + ... + 1 + 4 + 1
     * that is
     * '0000.[stuff].type\0'
     */
    char* filename = malloc(sizeof(char) * (name_len + 11));
    
    const char* type = vaht_resource_type(res);
    if (ext == NULL)
        ext = type;
    
    if (name)
    {
        sprintf(filename, "%04i.%s.%s", vaht_resource_id(res), name, ext);
    } else {
        sprintf(filename, "%04i.%s", vaht_resource_id(res), ext);
    }
    
    /* we don't need this anymore */
    if (name)
    {
        free(name);
        name = NULL;
    }
    
    char* directory;
    char* path;
    
    directory = path_join(out, type);
    path = path_join(directory, filename);
    
    free(directory);
    directory = NULL;
    free(filename);
    filename = NULL;
    
    return path;
}
Example #6
0
/*!
 * \brief An strcmp() for paths
 *
 * This function will normalize \a path1 and \a path2 before they are passed to
 * std::string::compare(). This way, extra slashes, '.', '..', etc. are handled
 * before the string comparison is performed.
 *
 * \note This function does not traverse the filesystem at all. It works purely
 *       on the given path strings.
 *
 * \return An integer less than, equal to, or greater than zero if \a path1 is
 *         found, respectively, to be less than, equal to, or greater than
 *         \a path2 lexicographically.
 */
int path_compare(const std::string &path1, const std::string &path2)
{
    if (path1.empty() || path2.empty()) {
        return false;
    }

    std::vector<std::string> path1_pieces(path_split(path1));
    std::vector<std::string> path2_pieces(path_split(path2));

    normalize_path(path1_pieces);
    normalize_path(path2_pieces);

    return path_join(path1_pieces).compare(path_join(path2_pieces));
}
Example #7
0
/*Runs BLAST on the coarse database and stores the results in a temporary
  XML file.*/
void blast_coarse(struct opt_args *args, uint64_t dbsize){
    char *blastn,
         *input_path = path_join(args->args[0], CABLAST_COARSE_FASTA),
         *blastn_command =
           "blastn -db  -outfmt 5 -query  -dbsize  -task blastn -evalue  "
           "> CaBLAST_temp_blast_results.xml";
    int command_length = strlen(blastn_command) + strlen(input_path) +
                                                  strlen(args->args[1]) + 31;

    blastn = malloc(command_length*sizeof(*blastn));
    assert(blastn);

    sprintf(blastn,
            "blastn -db %s -outfmt 5 -query %s -dbsize %lu -task blastn"
            " -evalue %s > CaBLAST_temp_blast_results.xml",
            input_path, args->args[1], dbsize, search_flags.coarse_evalue);

    if (!search_flags.hide_progress)
        fprintf(stderr, "%s\n", blastn);

    system(blastn);

    free(input_path);
    free(blastn);
}
Example #8
0
int main(void)
{
	char cwd[1024], *path, *ctx = tal_strdup(NULL, "ctx");

	plan_tests(6);

	if (!getcwd(cwd, sizeof(cwd)))
		abort();

	unlink("run-is_dir-dir-link");
	unlink("run-is_dir-file-link");
	unlink("run-is_dir-dir/file");
	rmdir("run-is_dir-dir");
	if (mkdir("run-is_dir-dir", 0700) != 0)
		abort();
	if (symlink("run-is_dir-dir", "run-is_dir-dir-link") != 0)
		abort();
	if (symlink("run-is_dir-dir/file", "run-is_dir-file-link") != 0)
		abort();
	close(open("run-is_dir-dir/file", O_WRONLY|O_CREAT, 0600));

	ok1(path_is_dir("run-is_dir-dir-link"));
	ok1(!path_is_dir("run-is_dir-file-link"));
	ok1(!path_is_dir("run-is_dir-dir/file"));
	ok1(path_is_dir("run-is_dir-dir"));

	path = path_join(ctx, cwd, "run-is_dir-dir/file");
	ok1(!path_is_dir(path));
	ok1(path_is_dir(cwd));

	tal_free(ctx);

	return exit_status();
}
Example #9
0
int lf_path_join(lua_State *L)
{
	char buffer[1024*2];
	int n = lua_gettop(L);
	int err;
	const char *base;
	const char *extend;
	size_t base_len, extend_len;

	if(n != 2)
		luaL_error(L, "path_join: incorrect number of arguments");

	luaL_checktype(L, 1, LUA_TSTRING);
	luaL_checktype(L, 2, LUA_TSTRING);
	
	base = lua_tolstring(L, 1, &base_len);
	extend = lua_tolstring(L, 2, &extend_len);
	err = path_join(base, base_len, extend, extend_len, buffer, 2*1024);
	if(err != 0)
	{
		luaL_error(L, "path_join: error %d, couldn't join\n\t'%s'\n  and\n\t'%s'",
			err,
			lua_tostring(L, 1),
			lua_tostring(L, 2));
	}
	
	lua_pushstring(L, buffer);
	return 1;
}
Example #10
0
File: helpers.c Project: csm/arrow
int
file_rmrf (const char *path)
{
  if (file_isdir (path))
	{
	  dirlist_t list;
	  if (file_listdir (path, &list) != 0)
		return -1;
	  int i;
	  for (i = 0; i < list.length; i++)
		{
		  if (strcmp (".", list.paths[i]) == 0
			  || strcmp ("..", list.paths[i]) == 0)
			continue;
		  char *next = path_join (path, list.paths[i]);
		  int ret = file_rmrf (next);
		  free (next);
		  if (ret != 0)
			{
			  file_free_dirlist (&list);
			  return ret;
			}
		}
	  file_free_dirlist (&list);
	  if (rmdir (path) != 0)
		return -1;
	}
  else if (file_isfile (path) || file_islink (path))
	{
	  return unlink (path);
	}
  return 0;
}
Example #11
0
static const char *stat_cache_path()
{
    const char *waitless_dir = getenv(WAITLESS_DIR);
    if (!waitless_dir)
        die("WAITLESS_DIR not set");
    return path_join(waitless_dir, stat_cache.name);
}
Example #12
0
int
rimraf(const char *path) {
  DIR *dir = opendir(path);
  if (NULL == dir) return -1;

  struct dirent *dp = NULL;
  while (NULL != (dp = readdir(dir))) {
    if (0 == strcmp(".", dp->d_name)
        || 0 == strcmp("..", dp->d_name)) continue;

    char *f = path_join(path, dp->d_name);
    if (NULL == f) return -1;

    struct stat s;
    if (0 != stat(f, &s)) return -1;
    if (s.st_mode & S_IFDIR) {
      // rimraf dirs
      if (-1 == rimraf(f)) return -1;
    } else {
      // unlink files
      if (-1 == unlink(f)) return -1;
    }
    free(f);
  }
  free(dp);
  closedir(dir);

  return rmdir(path);
}
Example #13
0
String path_which(const String &p_name) {

#ifdef WINDOWS_ENABLED
	Vector<String> exts = OS::get_singleton()->get_environment("PATHEXT").split(ENV_PATH_SEP, false);
#endif
	Vector<String> env_path = OS::get_singleton()->get_environment("PATH").split(ENV_PATH_SEP, false);

	if (env_path.empty())
		return String();

	for (int i = 0; i < env_path.size(); i++) {
		String p = path_join(env_path[i], p_name);

#ifdef WINDOWS_ENABLED
		for (int j = 0; j < exts.size(); j++) {
			String p2 = p + exts[j];

			if (FileAccess::exists(p2))
				return p2;
		}
#else
		if (FileAccess::exists(p))
			return p;
#endif
	}

	return String();
}
Example #14
0
int find_device(const char *id, const char *prefix, sd_device **ret) {
        _cleanup_free_ char *buf = NULL;

        assert(id);
        assert(ret);

        if (prefix && !path_startswith(id, prefix)) {
                buf = path_join(NULL, prefix, id);
                if (!buf)
                        return -ENOMEM;
                id = buf;
        }

        if (path_startswith(id, "/sys/"))
                return sd_device_new_from_syspath(ret, id);

        if (path_startswith(id, "/dev/")) {
                struct stat st;

                if (stat(id, &st) < 0)
                        return -errno;

                return device_new_from_stat_rdev(ret, &st);
        }

        return -EINVAL;
}
Example #15
0
static int exec_list(sd_device_enumerator *e, const char *action, Set *settle_set) {
        sd_device *d;
        int r;

        FOREACH_DEVICE_AND_SUBSYSTEM(e, d) {
                _cleanup_free_ char *filename = NULL;
                const char *syspath;

                if (sd_device_get_syspath(d, &syspath) < 0)
                        continue;

                if (arg_verbose)
                        printf("%s\n", syspath);
                if (arg_dry_run)
                        continue;

                filename = path_join(syspath, "uevent");
                if (!filename)
                        return log_oom();

                r = write_string_file(filename, action, WRITE_STRING_FILE_DISABLE_BUFFER);
                if (r < 0) {
                        log_debug_errno(r, "Failed to write '%s' to '%s', ignoring: %m", action, filename);
                        continue;
                }

                if (settle_set) {
                        r = set_put_strdup(settle_set, syspath);
                        if (r < 0)
                                return log_oom();
                }
        }
Example #16
0
string path_source_replace_includes(const string& source_, const string& path)
{
	/* our own little c preprocessor that replaces #includes with the file
	   contents, to work around issue of opencl drivers not supporting
	   include paths with spaces in them */
	string source = source_;
	const string include = "#include \"";
	size_t n, pos = 0;

	while((n = source.find(include, pos)) != string::npos) {
		size_t n_start = n + include.size();
		size_t n_end = source.find("\"", n_start);
		string filename = source.substr(n_start, n_end - n_start);

		string text, filepath = path_join(path, filename);

		if(path_read_text(filepath, text)) {
			text = path_source_replace_includes(text, path_dirname(filepath));
			source.replace(n, n_end + 1 - n, "\n" + text + "\n");
		}
		else
			pos = n_end;
	}

	return source;
}
Example #17
0
File: module.c Project: wrapl/wrapl
module_t *module_load(const char *Path, const char *File) {
	log_writef("Loading %s, path = %s.\n", File, Path);
	if (Path) return module_load_internal(Path, File, 0);
	//pthread_t Thread = pthread_self();
	//printf("<thread @ %x> Entering module_load:%d(%s, %s)\n", Thread, __LINE__, Path, File);
	const char *Alias = path_join("library:", File);
	pthread_mutex_lock(LibRivaMutex);
	module_t *Module = stringtable_get(Modules, Alias);
	pthread_mutex_unlock(LibRivaMutex);
	if (Module) {
		module_reload(Module);
		//printf("Found module %s = 0x%x\n", Alias, Module);
		//printf("<thread @ %x> Leaving module_load:%d(%s, %s)\n", Thread, __LINE__, Path, File);
		return Module;
	};
	for (path_node *Path = ModuleLibrary; Path; Path = Path->Next) {
		Module = module_load_internal(Path->Dir, File, Alias);
		if (Module) {
			//printf("<thread @ %x> Leaving module_load:%d(%s, %s)\n", Thread, __LINE__, Path, File);
			return Module;
		};
	};
	//printf("<thread @ %x> Leaving module_load:%d(%s, %s)\n", Thread, __LINE__, Path, File);
	return 0;
};
Example #18
0
// TODO: calling getcwd() every time might be slow.  This could be sped up by
// caching the current directory and intercepting chdir calls.
void remember_hash_path(struct hash *hash, const char *path)
{
    char cwd[PATH_MAX];
    if (!real_getcwd(cwd, PATH_MAX))
        die("remember_hash_path: getcwd failed: %s", strerror(errno));
    remember_hash_string(hash, path_join(cwd, path));
}
Example #19
0
string path_user_get(const string& sub)
{
	if(cached_user_path == "")
		cached_user_path = path_dirname(Sysutil::this_program_path());

	return path_join(cached_user_path, sub);
}
Example #20
0
static int extract_archive(struct vt_options* opt, vaht_archive* archive, char* out)
{
    uint16_t resource_types_count = vaht_archive_get_resource_types(archive);
    unsigned int t;
    for (t = 0; t < resource_types_count; t++)
    {
        const char* type = vaht_archive_get_resource_type(archive, t);
        
        /* check if we pass the type filter */
        if (opt->filter_type != NULL && strcmp(opt->filter_type, type) != 0)
        {
            /* we have failed the type filter! */
            continue;
        }

        /* if we're converting, but there's no extension for this type,
         * skip it
         */
        if (opt->convert && get_ext(opt, type) == NULL)
            continue;
        
        char* newdir = path_join(out, type);
        if (create_directory(opt, newdir))
        {
            free(newdir);
            return 1;
        }
        
        free(newdir);
        
        vaht_resource** resources = vaht_resources_open(archive, type);
        
        unsigned int r;
        for (r = 0; resources[r] != NULL; r++)
        {
            /* check if we pass the id filter */
            if (opt->filter_id != -1 && opt->filter_id != vaht_resource_id(resources[r]))
            {
                /* we failed the resource id filter! */
                continue;
            }
            
            char* ext = get_ext(opt, type);
            char* path = construct_path(resources[r], out, ext);
            
            if (write_resource(opt, resources[r], path))
            {
                vaht_resources_close(resources);
                free(path);
                return 1;
            }
            
            free(path);
        }
        
        vaht_resources_close(resources);
    }
    
    return 0;
}
Example #21
0
int load_modules() {
	plat_dir_t* dir = plat_opendir(mod_search_path);
	plat_dir_entry_t* d = NULL;
	char path[MODPATHLEN];

	if(!dir) {
		logmsg(LOG_CRIT, "Failed to open directory %s", mod_search_path);
		logerror();

		return -1;
	}

	while((d = plat_readdir(dir)) != NULL) {
		if( plat_dirent_hidden(d) ||
			plat_dirent_type(d) != DET_REG)
			continue;

		path_join(path, MODPATHLEN, mod_search_path, d->d_name, NULL);

		mod_load(path);
	}

	plat_closedir(dir);
	return 0;
}
Example #22
0
/* manage "stack of names" with possibly specified device priorities */
static int link_update(sd_device *dev, const char *slink, bool add) {
        _cleanup_free_ char *target = NULL, *filename = NULL, *dirname = NULL;
        char name_enc[PATH_MAX];
        const char *id_filename;
        int r;

        assert(dev);
        assert(slink);

        r = device_get_id_filename(dev, &id_filename);
        if (r < 0)
                return log_device_debug_errno(dev, r, "Failed to get id_filename: %m");

        util_path_encode(slink + STRLEN("/dev"), name_enc, sizeof(name_enc));
        dirname = path_join("/run/udev/links/", name_enc);
        if (!dirname)
                return log_oom();
        filename = path_join(dirname, id_filename);
        if (!filename)
                return log_oom();

        if (!add && unlink(filename) == 0)
                (void) rmdir(dirname);

        r = link_find_prioritized(dev, add, dirname, &target);
        if (r < 0) {
                log_device_debug(dev, "No reference left, removing '%s'", slink);
                if (unlink(slink) == 0)
                        (void) rmdir_parents(slink, "/");
        } else
                (void) node_symlink(dev, target, slink);

        if (add)
                do {
                        _cleanup_close_ int fd = -1;

                        r = mkdir_parents(filename, 0755);
                        if (!IN_SET(r, 0, -ENOENT))
                                break;
                        fd = open(filename, O_WRONLY|O_CREAT|O_CLOEXEC|O_TRUNC|O_NOFOLLOW, 0444);
                        if (fd < 0)
                                r = -errno;
                } while (r == -ENOENT);

        return r;
}
Example #23
0
string path_source_replace_includes(const string& source,
                                    const string& path,
                                    const string& source_filename)
{
	/* Our own little c preprocessor that replaces #includes with the file
	 * contents, to work around issue of opencl drivers not supporting
	 * include paths with spaces in them.
	 */

	string result = "";
	vector<string> lines;
	string_split(lines, source, "\n", false);

	for(size_t i = 0; i < lines.size(); ++i) {
		string line = lines[i];
		if(line[0] == '#') {
			string token = string_strip(line.substr(1, line.size() - 1));
			if(string_startswith(token, "include")) {
				token = string_strip(token.substr(7, token.size() - 7));
				if(token[0] == '"') {
					size_t n_start = 1;
					size_t n_end = token.find("\"", n_start);
					string filename = token.substr(n_start, n_end - n_start);
					string text, filepath = path_join(path, filename);
					if(path_read_text(filepath, text)) {
						/* Replace include directories with both current path
						 * and path extracted from the include file.
						 * Not totally robust, but works fine for Cycles kernel
						 * and avoids having list of include directories.x
						 */
						text = path_source_replace_includes(
						        text, path_dirname(filepath), filename);
						text = path_source_replace_includes(text, path, filename);
						/* Use line directives for better error messages. */
						line = line_directive(filepath, 1)
						     + token.replace(0, n_end + 1, "\n" + text + "\n")
						     + line_directive(path_join(path, source_filename), i);
					}
				}
			}
		}
		result += line + "\n";
	}

	return result;
}
Example #24
0
static int dopackage(lua_State* L)
{
	const char* oldScript;
	char oldcwd[8192];
	char filename[8192];
	int result;

	/* Clear the current global so included script can create a new one */
	lua_pushnil(L);
	lua_setglobal(L, "package");

	/* Remember the current state of things so I can restore after script runs */
	oldScript = currentScript;
	strcpy(oldcwd, io_getcwd());

	/* Try to locate the script file */
	strcpy(filename, lua_tostring(L, 1));
	if (!io_fileexists(filename))
	{
		strcpy(filename, path_join("", lua_tostring(L, 1), "lua"));
	}
	if (!io_fileexists(filename))
	{
		strcpy(filename, path_join(lua_tostring(L, 1), "premake.lua", ""));
	}

	if (!io_fileexists(filename))
	{
		lua_pushstring(L, "Unable to open package '");
		lua_pushvalue(L, 1);
		lua_pushstring(L, "'");
		lua_concat(L, 3);
		lua_error(L);
	}

	currentScript = filename;
	io_chdir(path_getdir(filename));

	result = lua_dofile(L, path_getname(filename));
	
	/* Restore the previous state */
	currentScript = oldScript;
	io_chdir(oldcwd);
	
	return 0;
}
Example #25
0
void TS::init( const string& modulename )
{
    data_search_subdir.push_back(modulename);
#ifndef WINRT
    char* datapath_dir = getenv("OPENCV_TEST_DATA_PATH");
#else
    char* datapath_dir = OPENCV_TEST_DATA_PATH;
#endif

    if( datapath_dir )
    {
        data_path = path_join(path_join(datapath_dir, modulename), "");
    }

    cv::redirectError((cv::ErrorCallback)tsErrorCallback, this);

    if( ::testing::GTEST_FLAG(catch_exceptions) )
    {
#if defined _WIN32
#ifdef _MSC_VER
        _set_se_translator( SEHTranslator );
#endif
#else
        for( int i = 0; tsSigId[i] >= 0; i++ )
            signal( tsSigId[i], signalHandler );
#endif
    }
    else
    {
#if defined _WIN32
#ifdef _MSC_VER
        _set_se_translator( 0 );
#endif
#else
        for( int i = 0; tsSigId[i] >= 0; i++ )
            signal( tsSigId[i], SIG_DFL );
#endif
    }

    if( params.use_optimized == 0 )
        cv::setUseOptimized(false);

    rng = RNG(params.rng_seed);
}
Example #26
0
string path_get(const string& sub)
{
	char *special = path_specials(sub);
	if(special != NULL)
		return special;

	if(cached_path == "")
		cached_path = path_dirname(Sysutil::this_program_path());

	return path_join(cached_path, sub);
}
Example #27
0
File: log.c Project: dyustc/searaft
static int delete_file(const char *logdir, uint64_t index) {
    char tmpbuf[50];
    snprintf(tmpbuf, 50, "%lld/%lld", (index / RAFT_MAX_FILES_PER_DIR), index);

    char *filename = path_join(logdir, tmpbuf);
    if(0 == unlink(filename)) {
        free(filename);
        return 1;
    }
    free(filename);
    return 0;
}
Example #28
0
File: types.c Project: 8l/awl
void awlenv_add_core_lib(awlenv* e) {
    char* awl_base = get_base_path();

    char* corelib = path_join(awl_base, "lib/core");

    awlval* args = awlval_sexpr();
    args = awlval_add(args, awlval_str(corelib));
    awlval_del(builtin_import(e, args));

    free(awl_base);
    free(corelib);
}
Example #29
0
void copy_includes(char *aspis_home, char * categories_file) {
   char* copy=strcat_malloc("cp ",aspis_home);
   
   char *p=path_join(copy,"phplib/AspisObject.php ");
   p=strcat_malloc(p,outpath);
   if (system(p)==-1) die("copy_includes failed");
   
   p=path_join(copy,"phplib/AspisTaints.php ");
   p=strcat_malloc(p,outpath);
   if (system(p)==-1) die("copy_includes failed");
   
   p=path_join(copy,"phplib/AspisLibrary.php ");
   p=strcat_malloc(p,outpath);
   if (system(p)==-1) die("copy_includes failed");
   
   p=path_join(copy,"phplib/php_functions.txt ");
   p=strcat_malloc(p,outpath);
   if (system(p)==-1) die("copy_includes failed");
   
   p = path_join(outpath, "AspisMain.php");
   p = strcat_malloc("mv AspisMainEdited.php ", p);
   if (system(p) == -1) die("copy_includes failed");
   
   copy=strcat_malloc("cp ",categories_file);
   p=strcat_malloc(copy," ");
   p=strcat_malloc(p,outpath);
   p=path_join(p,"AspisActive.categories");
   if (system(p)==-1) die("Copying of the categories file failed");
}
Example #30
0
static int writeWorkspace()
{
	int i;

	if (!io_openfile(path_join(prj_get_path(), prj_get_name(), "dsw")))
		return 0;

	io_print("Microsoft Developer Studio Workspace File, Format Version 6.00\n");
	io_print("# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n");
	io_print("\n");
	io_print("###############################################################################\n");
	io_print("\n");

	for (i = 0; i < prj_get_numpackages(); ++i)
	{
		prj_select_package(i);

		io_print("Project: \"%s\"=%s - Package Owner=<4>\n", prj_get_pkgname(), prj_get_pkgfilename("dsp"));
		io_print("\n");
		io_print("Package=<5>\n");
		io_print("{{{\n");
		io_print("}}}\n");
		io_print("\n");
		io_print("Package=<4>\n");
		io_print("{{{\n");

		/* Write package dependencies */
		prj_select_config(0);
		print_list(prj_get_links(), "", "", "", listPackageDeps);

		io_print("}}}\n");
		io_print("\n");
		io_print("###############################################################################\n");
		io_print("\n");
	}

	io_print("Global:\n");
	io_print("\n");
	io_print("Package=<5>\n");
	io_print("{{{\n");
	io_print("}}}\n");
	io_print("\n");
	io_print("Package=<3>\n");
	io_print("{{{\n");
	io_print("}}}\n");
	io_print("\n");
	io_print("###############################################################################\n");
	io_print("\n");

	io_closefile();
	return 1;
}