예제 #1
0
static char* createNewSalt(const char *path, struct passwd *userInfo)
{
    unlink(path);//in case the file already exists

    char *dir = strdup(path);
    dir[strlen(dir) - 14] = '\0';//remove kdewallet.salt
    mkpath(dir, userInfo);//create the path in case it does not exists
    free(dir);

    char *salt = gcry_random_bytes(KWALLET_PAM_SALTSIZE, GCRY_STRONG_RANDOM);
    FILE *fd = fopen(path, "w");

    //If the file can't be created
    if (fd == NULL) {
        syslog(LOG_ERR, "Couldn't open file: %s because: %d-%s", path, errno, strerror(errno));
        return NULL;
    }

    fwrite(salt, KWALLET_PAM_SALTSIZE, 1, fd);
    fclose(fd);

    if (chown(path, userInfo->pw_uid, userInfo->pw_gid) == -1) {
        syslog(LOG_ERR, "Couldn't change ownership of the created salt file");
    }

    return salt;
}
예제 #2
0
파일: config.c 프로젝트: bigdawgmj/git
int git_config_early(config_fn_t fn, void *data, const char *repo_config)
{
	int ret = 0, found = 0;
	const char *home = NULL;

	/* Setting $GIT_CONFIG makes git read _only_ the given config file. */
	if (config_exclusive_filename)
		return git_config_from_file(fn, config_exclusive_filename, data);
	if (git_config_system() && !access(git_etc_gitconfig(), R_OK)) {
		ret += git_config_from_file(fn, git_etc_gitconfig(),
					    data);
		found += 1;
	}

	home = getenv("HOME");
	if (git_config_global() && home) {
		char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
		if (!access(user_config, R_OK)) {
			ret += git_config_from_file(fn, user_config, data);
			found += 1;
		}
		free(user_config);
	}

	if (repo_config && !access(repo_config, R_OK)) {
		ret += git_config_from_file(fn, repo_config, data);
		found += 1;
	}

	ret += git_config_from_parameters(fn, data);
	if (config_parameters)
		found += 1;

	return ret == 0 ? found : ret;
}
예제 #3
0
bool move(const char* from, const char* to) {
/* Should this (or something similar) work?
    SHFILEOPSTRUCT fileOp = { 0 };
    fileOp.wFunc  = FO_MOVE;
    fileOp.pFrom  = from;
    fileOp.pTo    = to;
    fileOp.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR;
    return (SHFileOperation(&fileOp) == 0);
*/

    // the easy case...
    if (stricmp(from, to) == 0) {
        return true;
    }

    // try to get the parent name of the directory
    char dir[MAX_PATH] = { 0 };
    dirname(to, dir);
    if (strcmp(dir, "") == 0) {
        return false;
    }

    // try to make the path and move the file
    return (mkpath(dir)) ? (MoveFile(from, to) != 0) : false;
}
예제 #4
0
bool ViewGenerator::generate() const
{
    QStringList files;

    // Reserved word check
    if (excludedDirName()->contains(dstDir.dirName())) {
        qCritical("Reserved word error. Please use another word.  View name: %s", qPrintable(dstDir.dirName()));
        return false;
    }

    mkpath(dstDir);

    if (!TableSchema(tableName).exists()) {
        qCritical("table not found, %s", qPrintable(tableName));
        return false;
    }

    // Generates view files
    files << generateViews();

    // Generates a project file
    QDir dir(QDir::cleanPath(dstDir.filePath("..")));
    ProjectFileGenerator progen(dir.filePath("views.pro"));
    return progen.generate(QStringList(), VIEWS_PROJECT);
}
예제 #5
0
void PlaylistInterface::set_url(std::string &path, std::string &filename)
{
	//std::cout << " seturl " << std::endl;
	playlist_path = path;
	playlist_name = filename;
	playlist_url = playlist_path + "/" + playlist_name;
	mkpath(playlist_path.c_str(), 0777);
}
예제 #6
0
파일: refs.c 프로젝트: ratnikov/git
struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1)
{
	char refpath[PATH_MAX];
	if (check_ref_format(ref))
		return NULL;
	strcpy(refpath, mkpath("refs/%s", ref));
	return lock_ref_sha1_basic(refpath, old_sha1, 0, NULL);
}
예제 #7
0
파일: xfeutils.cpp 프로젝트: tindzk/Xfe
// Create trashinfo file based on the pathname and the trashpathname
FXint createTrashinfo(FXString pathname, FXString trashpathname, FXString trashfileslocation, FXString trashinfolocation)
{
	// Create trash can files if it doesn't exist
	if (!exists(trashfileslocation))
	{
		FXint mask=umask(0);
		umask(mask);
		FXint ret=mkpath(trashfileslocation.text(),511 & ~mask);
		return ret;
	}
	
	// Create trash can info if it doesn't exist
	if (!exists(trashinfolocation))
	{
		FXint mask=umask(0);
		umask(mask);
		FXint ret=mkpath(trashinfolocation.text(),511 & ~mask);
		return ret;

	}
	
	// Deletion date
	struct timeval tv;
	gettimeofday(&tv,NULL);
	FXString deldate=FXSystem::time("%FT%T",tv.tv_sec);
	
	// Trash info path name
	FXString trashinfopathname=trashinfolocation+PATHSEPSTRING+FXPath::name(trashpathname)+".trashinfo";

	// Create trash info file
	FILE *fp;
	FXint ret;
	if ((fp=fopen(trashinfopathname.text(),"w"))!=NULL)
	{
		fprintf(fp,"[Trash Info]\n");
		fprintf(fp,"Path=%s\n",pathname.text());
		fprintf(fp,"DeletionDate=%s\n",deldate.text());
		fclose(fp);
		ret=0;
	}
	else
		ret=-1;

	return ret;
}
예제 #8
0
int git_get_config(const char *key, char *buffer, int size)
{
	char *local, *global, *globalxdg;
	const char *home, *system;
	struct config_buf buf;

	buf.buf=buffer;
	buf.size=size;
	buf.seen = 0;
	buf.key = key;

	home = get_windows_home_directory();
	if (home)
	{
		global = xstrdup(mkpath("%s/.gitconfig", home));
		globalxdg = xstrdup(mkpath("%s/.config/git/config", home));
	}
	else
	{
		global = NULL;
		globalxdg = NULL;
	}

	system = git_etc_gitconfig();

	local = git_pathdup("config");

	if ( !buf.seen)
		git_config_with_options(get_config, &buf, local, NULL, 1);
	if (!buf.seen && global)
		git_config_with_options(get_config, &buf, global, NULL, 1);
	if (!buf.seen && globalxdg)
		git_config_with_options(get_config, &buf, globalxdg, NULL, 1);
	if (!buf.seen && system)
		git_config_with_options(get_config, &buf, system, NULL, 1);

	if(local)
		free(local);
	if(global)
		free(global);
	if (globalxdg)
		free(globalxdg);

	return !buf.seen;
}
예제 #9
0
void ssa_db_save(const char *path_dir, const struct ssa_db *p_ssa_db,
		 enum ssa_db_helper_mode mode)
{
	FILE *fd;
	int i = 0, tbls_n = 0;
	char buffer[SSA_DB_HELPER_PATH_MAX] = {};

	ssa_log_func(SSA_LOG_DEFAULT);
	assert(p_ssa_db);

	mkpath(path_dir, S_IRWXU | S_IRWXG | S_IRWXO);

	tbls_n = ntohll(p_ssa_db->db_table_def.set_count);

	/****************** Dumping db_def record *******************/
	sprintf(buffer, "%s/%s", path_dir, SSA_DB_HELPER_DB_DEF_NAME);
	fd = fopen(buffer, SSA_DB_HELPER_FILE_WRITE_MODE_TXT);
	if (!fd) {
		ssa_log_err(SSA_LOG_DEFAULT, "Failed opening %s file\n", buffer);
		return;
	}
	ssa_db_db_def_dump(fd, &p_ssa_db->db_def);
	fclose(fd);
	/************************************************************/

	for (i = 0; i < tbls_n; ++i) {
		if (p_ssa_db->p_def_tbl[i].type == DBT_TYPE_DATA) {
			int j = 0, k = 0;
			struct db_id id = p_ssa_db->p_def_tbl[i].id; /* Data table id */

			for (j = 0; j < tbls_n; j++)
				if (p_ssa_db->p_def_tbl[j].type == DBT_TYPE_DEF &&
				    ntohl(p_ssa_db->p_def_tbl[j].ref_table_id) == id.table)
					break;

			for (k = 0; k < p_ssa_db->data_tbl_cnt; k++)
				if (p_ssa_db->p_db_tables[k].id.table == id.table)
					break;

			/* creating a directory for each dataset */
			sprintf(buffer, "mkdir \"%s/%s\"",
				path_dir, p_ssa_db->p_def_tbl[i].name);
			if (system(buffer) != 0) {
				ssa_log_err(SSA_LOG_DEFAULT, "unable to create %s/%s directory - %s (%d)\n",
					    path_dir, p_ssa_db->p_def_tbl[i].name, strerror(errno), errno);
				break;
			}

			/* dump dataset and its field dataset */
			sprintf(buffer, "%s/%s",
				path_dir, p_ssa_db->p_def_tbl[i].name);
			ssa_db_tbl_dump(buffer, p_ssa_db, i, j, k, mode);
			ssa_log(SSA_LOG_DEFAULT, "%s table was saved\n",
				p_ssa_db->p_def_tbl[i].name);
		}
	}
}
예제 #10
0
int run_hook(const char *index_file, const char *name, ...)
{
	struct child_process hook;
	struct argv_array argv = ARGV_ARRAY_INIT;
	const char *p, *env[2];
	char index[PATH_MAX];
	va_list args;
	int ret;

	// If this is not reset to NULL, then strange stuff happens
	hook_directory = NULL;

	// Load the configuration for hooks.directory
	git_config(git_hook_config, NULL);

	// If the configuration is not set for hooks directory, set it to the
	// default GIT_PATH/hooks directory that we all know and love.
	if(hook_directory == NULL)
		hook_directory = git_path("hooks");

	if (access(mkpath("%s/%s", hook_directory, name), X_OK) < 0)
		return 0;

	va_start(args, name);
	argv_array_push(&argv, mkpath("%s/%s", hook_directory, name));
	while ((p = va_arg(args, const char *)))
		argv_array_push(&argv, p);
	va_end(args);

	memset(&hook, 0, sizeof(hook));
	hook.argv = argv.argv;
	hook.no_stdin = 1;
	hook.stdout_to_stderr = 1;
	if (index_file) {
		snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
		env[0] = index;
		env[1] = NULL;
		hook.env = env;
	}

	ret = run_command(&hook);
	argv_array_clear(&argv);
	return ret;
}
예제 #11
0
파일: clone.c 프로젝트: IAmAnubhavSaini/git
static char *get_repo_path(const char *repo, int *is_bundle)
{
	static char *suffix[] = { "/.git", "", ".git/.git", ".git" };
	static char *bundle_suffix[] = { ".bundle", "" };
	struct stat st;
	int i;

	for (i = 0; i < ARRAY_SIZE(suffix); i++) {
		const char *path;
		path = mkpath("%s%s", repo, suffix[i]);
		if (stat(path, &st))
			continue;
		if (S_ISDIR(st.st_mode) && is_git_directory(path)) {
			*is_bundle = 0;
			return xstrdup(absolute_path(path));
		} else if (S_ISREG(st.st_mode) && st.st_size > 8) {
			/* Is it a "gitfile"? */
			char signature[8];
			int len, fd = open(path, O_RDONLY);
			if (fd < 0)
				continue;
			len = read_in_full(fd, signature, 8);
			close(fd);
			if (len != 8 || strncmp(signature, "gitdir: ", 8))
				continue;
			path = read_gitfile(path);
			if (path) {
				*is_bundle = 0;
				return xstrdup(absolute_path(path));
			}
		}
	}

	for (i = 0; i < ARRAY_SIZE(bundle_suffix); i++) {
		const char *path;
		path = mkpath("%s%s", repo, bundle_suffix[i]);
		if (!stat(path, &st) && S_ISREG(st.st_mode)) {
			*is_bundle = 1;
			return xstrdup(absolute_path(path));
		}
	}

	return NULL;
}
예제 #12
0
파일: flist.c 프로젝트: ETredgo/NetflowDB
int SetupSubDir(char *dir, char *subdir, char *error, size_t errlen ) {
char *p, path[MAXPATHLEN];
struct stat stat_buf;
size_t	sublen, pathlen;
int err;

	error[0] = '\0';

	path[0] = '\0';
	strncat(path, dir, MAXPATHLEN-1);
	path[MAXPATHLEN-1] = '\0';

	sublen  = strlen(subdir);
	pathlen = strlen(path);
	// set p as reference between path and subdir
	if ( (sublen + pathlen + 2) >= (MAXPATHLEN-1) ) {	// +2 : add 1 for '/'
		snprintf(error, errlen, "Path '%s': too long", path);
		return 0;
	}

	p = path + pathlen;	// points to '\0' of path
	*p++ = '/';
	*p   = '\0';

	strncat(path, subdir, MAXPATHLEN-pathlen-2);	// +2: add 1 for '/'

	// our cwd is basedir ( -l ) so test if, dir exists
	if ( stat(path, &stat_buf) == 0 ) {
		if ( S_ISDIR(stat_buf.st_mode) ) {
			// sub directory already exists
			return 1;
		} else {
			// an entry with this name exists, but it's not a directory
			snprintf(error, errlen, "Path '%s': %s ", path, strerror(ENOTDIR));
			return 0;
		}
	}

	// no such entry exists - try to create the directory, assuming path below exists
	err = mkdir(path, dir_mode);
	if ( err == 0 ) // success
		return 1;

	// else errno is set
	if ( errno == ENOENT ) { // we need to create intermediate directories as well
		err = mkpath(path, p, mode, dir_mode, error, errlen);
		if ( err == 0 ) // creation was successful
			return 1;
	} else {
		snprintf(error, errlen, "mkdir() error for '%s': %s\n", path, strerror(errno));
	}

	// anything else failed and error string is set
	return 0;

} // End of SetupSubDir
예제 #13
0
파일: fs.cpp 프로젝트: pombredanne/pepper
// mkdir() for a complete path
void mkpath(const std::string &path)
{
	std::string dir = dirname(path);
	struct stat statbuf;
	if (stat(dir.c_str(), &statbuf) != 0) {
		mkpath(dir);
	}

	mkdir(path);
}
예제 #14
0
파일: gitdll.c 프로젝트: omnibs/TortoiseGit
int git_get_config(const char *key, char *buffer, int size, char *git_path)
{
	char *local,*global,*system_wide,*p;
	struct config_buf buf;
	buf.buf=buffer;
	buf.size=size;
	buf.seen = 0;
	buf.key = key;

	local=global=system_wide=NULL;

	//local = config_exclusive_filename;
	if (!local) {
		const char *home = get_windows_home_directory();

		local=p= git_pathdup("config");
		if(git_path&&strlen(git_path))
		{
			local=xstrdup(mkpath("%s/%s", git_path, p));
			free(p);
		}
		if (git_config_global() && home)
			global = xstrdup(mkpath("%s/.gitconfig", home));
		if (git_config_system())
			system_wide = git_etc_gitconfig();
	}

	if ( !buf.seen)
		git_config_from_file(get_config, local, &buf);
	if (!buf.seen && global)
		git_config_from_file(get_config, global, &buf);
	if (!buf.seen && system_wide)
		git_config_from_file(get_config, system_wide, &buf);

	if(local)
		free(local);
	if(global)
		free(global);
	//if(system_wide)
	//	free(system_wide);

	return !buf.seen;
}
예제 #15
0
파일: clone.c 프로젝트: 2572/git
static int add_one_reference(struct string_list_item *item, void *cb_data)
{
	char *ref_git;
	const char *repo;
	struct strbuf alternate = STRBUF_INIT;

	/* Beware: read_gitfile(), real_path() and mkpath() return static buffer */
	ref_git = xstrdup(real_path(item->string));

	repo = read_gitfile(ref_git);
	if (!repo)
		repo = read_gitfile(mkpath("%s/.git", ref_git));
	if (repo) {
		free(ref_git);
		ref_git = xstrdup(repo);
	}

	if (!repo && is_directory(mkpath("%s/.git/objects", ref_git))) {
		char *ref_git_git = mkpathdup("%s/.git", ref_git);
		free(ref_git);
		ref_git = ref_git_git;
	} else if (!is_directory(mkpath("%s/objects", ref_git))) {
		struct strbuf sb = STRBUF_INIT;
		if (get_common_dir(&sb, ref_git))
			die(_("reference repository '%s' as a linked checkout is not supported yet."),
			    item->string);
		die(_("reference repository '%s' is not a local repository."),
		    item->string);
	}

	if (!access(mkpath("%s/shallow", ref_git), F_OK))
		die(_("reference repository '%s' is shallow"), item->string);

	if (!access(mkpath("%s/info/grafts", ref_git), F_OK))
		die(_("reference repository '%s' is grafted"), item->string);

	strbuf_addf(&alternate, "%s/objects", ref_git);
	add_to_alternates_file(alternate.buf);
	strbuf_release(&alternate);
	free(ref_git);
	return 0;
}
예제 #16
0
파일: stabs.c 프로젝트: 00001/plan9port
static Ftypes*
mkftypes(char *dir, char *name)
{
	Ftypes *f;

	f = emalloc(sizeof(*f));
	f->file = mkpath(dir, name);
	f->next = allftypes;
	allftypes = f;
	return f;
}
예제 #17
0
파일: handy.c 프로젝트: goneri/burp
int build_path(const char *datadir, const char *fname, size_t flen, char **rpath, const char *limit)
{
	//logp("build path: '%s/%s'\n", datadir, fname);
	if(!(*rpath=prepend_s(datadir, fname, flen))) return -1;
	if(mkpath(rpath, limit))
	{
		if(*rpath) { free(*rpath); *rpath=NULL; }
		return -1;
	}
	return 0;
}
예제 #18
0
파일: daemon.c 프로젝트: zyklide/vnstat
void preparevnstatdir(const char *file, const char *user, const char *group)
{
	int len, i, lastslash=0;
	char *path, *base;

	if (file == NULL) {
		return;
	}

	len = strlen(file);
	if (len<2) {
		return;
	}

	if (file[len-1] == '/') {
		return;
	}

	path = strdup(file);
	if (path == NULL) {
		return;
	}

	/* verify that path ends with vnstat or vnstatd */
	base = basename(dirname(path));
	if (strcmp(base, "vnstat")!=0 && strcmp(base, "vnstatd")!=0) {
		free(path);
		return;
	}
	free(path);

	path = strdup(file);
	if (path == NULL) {
		return;
	}

	/* extract path */
	for (i=0; i<len; i++) {
		if (path[i] == '/') {
			lastslash = i;
		}
	}
	if (lastslash == 0) {
		free(path);
		return;
	}
	path[lastslash] = '\0';

	/* create & chmod if needed */
	if (mkpath(path, 0775)) {
		updatedirowner(path, user, group);
	}
	free(path);
}
예제 #19
0
traceFileWriterTSV::traceFileWriterTSV(std::string outFName) {
  // Create the directory in which outFName resides, if it does not already exist
  /*boost::filesystem::path p(outFName);
  boost::system::error_code ec;
  if(!boost::filesystem::create_directory(p.parent_path(), ec)) { cerr << "traceFileWriterTSV::traceFileWriterTSV ERROR creating directory \""<<p.parent_path().string()<<"\"! "<<ec.message()<<endl; assert(0); }*/
  mkpath(outFName, 0755, false);
  
  out.open(outFName.c_str(), std::ofstream::out);
  if(!out.is_open()) { cerr << "traceFileWriterTSV::traceFileWriterTSV() ERROR opening file \""<<outFName<<"\" for writing! "<<strerror(errno)<<endl; assert(0); }
  numObservations=0;
}
예제 #20
0
파일: fsops.c 프로젝트: pkdevbox/burp
int build_path(const char *datadir, const char *fname, char **rpath, const char *limit)
{
	//logp("build path: '%s/%s'\n", datadir, fname);
	if(!(*rpath=prepend_s(datadir, fname))) return -1;
	if(mkpath(rpath, limit))
	{
		free_w(rpath);
		return -1;
	}
	return 0;
}
예제 #21
0
파일: clone.c 프로젝트: Fafinou/git
static int add_one_reference(struct string_list_item *item, void *cb_data)
{
	char *ref_git;
	struct strbuf alternate = STRBUF_INIT;

	/* Beware: real_path() and mkpath() return static buffer */
	ref_git = xstrdup(real_path(item->string));
	if (is_directory(mkpath("%s/.git/objects", ref_git))) {
		char *ref_git_git = xstrdup(mkpath("%s/.git", ref_git));
		free(ref_git);
		ref_git = ref_git_git;
	} else if (!is_directory(mkpath("%s/objects", ref_git)))
		die(_("reference repository '%s' is not a local directory."),
		    item->string);

	strbuf_addf(&alternate, "%s/objects", ref_git);
	add_to_alternates_file(alternate.buf);
	strbuf_release(&alternate);
	free(ref_git);
	return 0;
}
예제 #22
0
파일: deleteme.c 프로젝트: pkdevbox/burp
int deleteme_move(struct sdirs *sdirs, const char *fullpath, const char *path,
	struct conf **cconfs)
{
	int ret=-1;
	char *tmp=NULL;
	char *dest=NULL;
	int attempts=0;
	struct stat statp;
	char suffix[16]="";
	char *timestamp=NULL;

	if(lstat(fullpath, &statp) && errno==ENOENT)
	{
		// The path to move aside does not exist.
		// Treat this as OK.
		ret=0;
		goto end;
	}

	if(!(tmp=prepend_s(sdirs->deleteme, path))
	  || mkpath(&tmp, sdirs->deleteme)
	  || !(dest=prepend("", tmp)))
		goto end;

	// Try to generate destination paths if the desired one is already
	// taken.
	while(1)
	{
		if(lstat(dest, &statp)) break;
		snprintf(suffix, sizeof(suffix), ".%d", ++attempts);
		free_w(&dest);
		if(!(dest=prepend(tmp, suffix)))
			goto end;
		if(attempts>=100) break; // Give up.
	}

	// Paranoia - really do not want the deleteme directory to be loaded
	// as if it were a normal storage directory, so remove the timestamp.
	if(!(timestamp=prepend_s(fullpath, "timestamp")))
		goto end;
	unlink(timestamp);

	// Possible race condition is of no consequence, as the destination
	// will need to be deleted at some point anyway.
	ret=do_rename(fullpath, dest);

end:
	free_w(&dest);
	free_w(&tmp);
	free_w(&timestamp);
	return ret;
}
예제 #23
0
파일: log.c 프로젝트: FabrizioFabbe/silc
int log_start_logging(LOG_REC *log)
{
	char *dir;

	g_return_val_if_fail(log != NULL, FALSE);

	if (log->handle != -1)
		return TRUE;

	/* Append/create log file */
	g_free_not_null(log->real_fname);
	log->real_fname = log_filename(log);

	if (log->real_fname != NULL &&
	    strcmp(log->real_fname, log->fname) != 0) {
		/* path may contain variables (%time, $vars),
		   make sure the directory is created */
		dir = g_dirname(log->real_fname);
		mkpath(dir, log_dir_create_mode);
		g_free(dir);
	}

	log->handle = log->real_fname == NULL ? -1 :
		open(log->real_fname, O_WRONLY | O_APPEND | O_CREAT,
		     log_file_create_mode);
	if (log->handle == -1) {
		signal_emit("log create failed", 1, log);
		log->failed = TRUE;
		return FALSE;
	}
#ifdef HAVE_FCNTL
        memset(&lock, 0, sizeof(lock));
	lock.l_type = F_WRLCK;
	if (fcntl(log->handle, F_SETLK, &lock) == -1 && errno == EACCES) {
		close(log->handle);
		log->handle = -1;
		signal_emit("log locked", 1, log);
		log->failed = TRUE;
		return FALSE;
	}
#endif
	lseek(log->handle, 0, SEEK_END);

	log->opened = log->last = time(NULL);
	log_write_timestamp(log->handle,
			    settings_get_str("log_open_string"),
			    "\n", log->last);

	signal_emit("log started", 1, log);
	log->failed = FALSE;
	return TRUE;
}
예제 #24
0
static int prune_tmp_object(const char *path, const char *filename)
{
	const char *fullpath = mkpath("%s/%s", path, filename);
	struct stat st;
	if (lstat(fullpath, &st))
		return error("Could not stat '%s'", fullpath);
	if (st.st_mtime > expire)
		return 0;
	printf("Removing stale temporary file %s\n", fullpath);
	if (!show_only)
		unlink_or_warn(fullpath);
	return 0;
}
예제 #25
0
파일: refs.c 프로젝트: ratnikov/git
int refname_match(const char *abbrev_name, const char *full_name, const char **rules)
{
	const char **p;
	const int abbrev_name_len = strlen(abbrev_name);

	for (p = rules; *p; p++) {
		if (!strcmp(full_name, mkpath(*p, abbrev_name_len, abbrev_name))) {
			return 1;
		}
	}

	return 0;
}
예제 #26
0
QString ZealDocsetsRegistry::docsetsDir(){
    if(settings.contains("docsetsDir")) {
        return settings.value("docsetsDir").toString();
    } else {
        auto dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
        auto dataDir = QDir(dataLocation);
        if(!dataDir.cd("docsets")) {
            dataDir.mkpath("docsets");
        }
        dataDir.cd("docsets");
        return dataDir.absolutePath();
    }
}
예제 #27
0
파일: stabs.c 프로젝트: 00001/plan9port
static Ftypes*
findftypes(char *dir, char *name)
{
	char *s;
	Ftypes *f, *found;

	found = nil;
	s = mkpath(dir, name);
	for(f=allftypes; f; f=f->next)
		if(strcmp(f->file, s) == 0)
			found = f;
	return found;
}
예제 #28
0
static bool createNewApplication(const QString &name)
{
    if (name.isEmpty()) {
         qCritical("invalid argument");
        return false;
    }

    QDir dir(".");
    if (dir.exists(name)) {
        qCritical("directory already exists");
        return false;
    }
    if (!dir.mkdir(name)) {
        qCritical("failed to create a directory %s", qPrintable(name));
        return false;
    }
    printf("  created   %s\n", qPrintable(name));

    // Creates sub-directories
    for (QStringListIterator i(*subDirs()); i.hasNext(); ) {
        const QString &str = i.next();
        QString d = name + SEP + str;
        if (!mkpath(dir, d)) {
            return false;
        }
    }

    // Copies files
    copy(dataDirPath + "app.pro", name + SEP + name + ".pro");

    for (QStringListIterator it(*filePaths()); it.hasNext(); ) {
        const QString &path = it.next();
        QString filename = QFileInfo(path).fileName();
        QString dst = name + SEP + path;
        copy(dataDirPath + filename, dst);

        // Replaces a string in application.ini file
        if (filename == "application.ini") {
            replaceString(dst, "$SessionSecret$", randomString(30));
        }
    }

#ifdef Q_OS_WIN
    // Add dummy model files
    ProjectFileGenerator progen(name + SEP + D_MODELS + "models.pro");
    QStringList dummy = { "_dummymodel.h", "_dummymodel.cpp" };
    progen.add(dummy);
#endif

    return true;
}
예제 #29
0
BOOL CMPath::AddDir(const CMString& sPathName)
{
    CMString strPath=m_sPath+sPathName;
	if(!PathExist(strPath))
	{
		//权限700
		if (mkpath((const char*)strPath, 0700) != 0) {
			CM_ERRP("mkdir %s error no %d",(const char*)strPath, errno);
			return FALSE;
		}
	}
    m_sPath = strPath;
    return TRUE;
}
예제 #30
0
파일: prune.c 프로젝트: DavidGould/git
int cmd_prune(int argc, const char **argv, const char *prefix)
{
	struct rev_info revs;
	struct progress *progress = NULL;
	const struct option options[] = {
		OPT__DRY_RUN(&show_only, N_("do not remove, show only")),
		OPT__VERBOSE(&verbose, N_("report pruned objects")),
		OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
		OPT_DATE(0, "expire", &expire,
			 N_("expire objects older than <time>")),
		OPT_END()
	};
	char *s;

	expire = ULONG_MAX;
	save_commit_buffer = 0;
	read_replace_refs = 0;
	init_revisions(&revs, prefix);

	argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
	while (argc--) {
		unsigned char sha1[20];
		const char *name = *argv++;

		if (!get_sha1(name, sha1)) {
			struct object *object = parse_object(sha1);
			if (!object)
				die("bad object: %s", name);
			add_pending_object(&revs, object, "");
		}
		else
			die("unrecognized argument: %s", name);
	}

	if (show_progress == -1)
		show_progress = isatty(2);
	if (show_progress)
		progress = start_progress_delay("Checking connectivity", 0, 0, 2);

	mark_reachable_objects(&revs, 1, progress);
	stop_progress(&progress);
	prune_object_dir(get_object_directory());

	prune_packed_objects(show_only);
	remove_temporary_files(get_object_directory());
	s = xstrdup(mkpath("%s/pack", get_object_directory()));
	remove_temporary_files(s);
	free(s);
	return 0;
}