本文整理汇总了C++中create_dir函数的典型用法代码示例。如果您正苦于以下问题:C++ create_dir函数的具体用法?C++ create_dir怎么用?C++ create_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_dir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: worker
void *
worker(void *args)
{
int id = (long) args;
int l1n, l2n, l3n;
char dirname[1024];
affinity_set(id);
sprintf(dirname, "%s%d", PATH_PREFIX, id);
create_dir(dirname);
for (l1n = 0; l1n < NR_SUBDIRS; l1n++) {
sprintf(dirname, "%s%d/%d", PATH_PREFIX, id, l1n);
create_dir(dirname);
for (l2n = 0; l2n < NR_SUBDIRS; l2n++) {
sprintf(dirname, "%s%d/%d/%d", PATH_PREFIX, id, l1n, l2n);
create_dir(dirname);
for (l3n = 0; l3n < NR_SUBDIRS; l3n++) {
sprintf(dirname, "%s%d/%d/%d/%d", PATH_PREFIX, id, l1n, l2n, l3n);
create_dir(dirname);
}
}
}
return NULL;
}
开发者ID:rousya,项目名称:linux-scalability-benchmark,代码行数:27,代码来源:dirmaker_fork.c
示例2: _get_log_filename
static char *
_get_log_filename(const char * const other, const char * const login,
GDateTime *dt, gboolean create)
{
gchar *chatlogs_dir = files_get_chatlog_dir();
GString *log_file = g_string_new(chatlogs_dir);
g_free(chatlogs_dir);
gchar *login_dir = str_replace(login, "@", "_at_");
g_string_append_printf(log_file, "/%s", login_dir);
if (create) {
create_dir(log_file->str);
}
free(login_dir);
gchar *other_file = str_replace(other, "@", "_at_");
g_string_append_printf(log_file, "/%s", other_file);
if (create) {
create_dir(log_file->str);
}
free(other_file);
gchar *date = g_date_time_format(dt, "/%Y_%m_%d.log");
g_string_append(log_file, date);
char *result = strdup(log_file->str);
g_string_free(log_file, TRUE);
return result;
}
开发者ID:backalor,项目名称:profanity,代码行数:30,代码来源:chat_log.c
示例3: test_getNextInTree_UriList_RootWithOnlyThreeDirs
static void test_getNextInTree_UriList_RootWithOnlyThreeDirs() {
// No before!
create_dir(testdir_path, "");
create_dir(testdir_path, "/apa");
create_dir(testdir_path, "/bepa");
create_dir(testdir_path, "/cepa");
GSList *uri_list = NULL;
uri_list = add_path_to_list(uri_list, testdir_path, "/bepa.png");
uri_list = add_path_to_list(uri_list, testdir_path, "/cepa.jpg");
GError *error = NULL;
GNode *tree = create_tree_from_uri_list(uri_list, TRUE, TRUE, NULL, NULL, &error);
assert_error_is_null(error);
free(error);
g_slist_free_full(uri_list, free);
assert_trees_equal("Get Next ─ Uri List ─ Input is Root with only three dirs", tree, get_next_in_tree(tree));
assert_trees_equal("Get First ─ Uri List ─ Input is Root with only three dirs", tree, get_first_in_tree(tree));
assert_trees_equal("Get Last ─ Uri List ─ Input is Root with only three dirs", tree, get_last_in_tree(tree));
free_whole_tree(tree);
after();
}
开发者ID:sjoblomj,项目名称:Viewnior,代码行数:25,代码来源:test-tree-next-nofiles.c
示例4: find_userdir
void
System::init_directories()
{
if (userdir.empty())
userdir = find_userdir();
std::string statdir = get_userdir();
create_dir(statdir);
// FIXME: We need a better seperation between user created levels,
// FIXME: third party levels and levels from the base distri
create_dir(statdir + "levels/");
create_dir(statdir + "levels/dist");
create_dir(statdir + "themes/");
// Savegames (FIXME: rename to savegames/?)
create_dir(statdir + "savegames/");
// User created images
create_dir(statdir + "images/");
// Thumbnail cache
create_dir(statdir + "cache/");
// Recorded demos will per default be writen in this directory
create_dir(statdir + "demos/");
// User created images
create_dir(statdir + "backup/");
// Screenshots will be dumped to that directory:
create_dir(statdir + "screenshots/");
}
开发者ID:jcs12311,项目名称:pingus,代码行数:34,代码来源:system.cpp
示例5: create_path
/* Walk along a path, making sure that all directories in that path exist,
* creating them if necessary.
*/
static int create_path(pool *p, const char *path, const char *user,
uid_t dir_uid, gid_t dir_gid, mode_t dir_mode,
uid_t dst_uid, gid_t dst_gid, mode_t dst_mode) {
char *currpath = NULL, *tmppath = NULL;
struct stat st;
pr_fs_clear_cache();
if (pr_fsio_stat(path, &st) == 0) {
/* Path already exists, nothing to be done. */
errno = EEXIST;
return -1;
}
pr_event_generate("core.create-home", user);
/* The special-case values of -1 for dir UID/GID mean that the destination
* UID/GID should be used for the parent directories.
*/
if (dir_uid == (uid_t) -1) {
dir_uid = dst_uid;
}
if (dir_gid == (gid_t) -1) {
dir_gid = dst_gid;
}
pr_trace_msg(trace_channel, 5, "creating home directory '%s' for user '%s'",
path, user);
pr_log_debug(DEBUG3, "creating home directory '%s' for user '%s'", path,
user);
tmppath = pstrdup(p, path);
currpath = "/";
while (tmppath && *tmppath) {
char *currdir = strsep(&tmppath, "/");
currpath = pdircat(p, currpath, currdir, NULL);
/* If tmppath is NULL, we are creating the last part of the path, so we
* use the configured mode, and chown it to the given UID and GID.
*/
if (tmppath == NULL ||
(*tmppath == '\0')) {
create_dir(currpath, dst_uid, dst_gid, dst_mode);
} else {
create_dir(currpath, dir_uid, dir_gid, dir_mode);
}
pr_signals_handle();
}
pr_trace_msg(trace_channel, 5, "home directory '%s' created", path);
pr_log_debug(DEBUG3, "home directory '%s' created", path);
return 0;
}
开发者ID:Distrotech,项目名称:proftpd,代码行数:59,代码来源:mkhome.c
示例6: main
int
main(void)
{
int cmd, ret;
vfs_init(&vfs);
// Set up filesystem
create_dir(&vfs, "/etc");
crond = create_dir(&vfs, "/etc/crond");
create_dir(&vfs, "/home");
pwd = create_dir(&vfs, "/home/user");
pwd->owner = USER_UID;
while (1) {
// Simulate a period cron job
do_cron();
if (read_all(STDIN, &cmd, sizeof(cmd)) != sizeof(cmd))
continue;
if (cmd == -1)
break;
switch (cmd) {
case CD:
ret = do_cd();
break;
case READ:
ret = do_read();
break;
case WRITE:
ret = do_write();
break;
case LN:
ret = do_ln();
break;
case RM:
ret = do_rm();
break;
default:
continue;
}
write_all(STDOUT, &ret, sizeof(ret));
}
vfs_destroy(&vfs);
return 0;
}
开发者ID:trailofbits,项目名称:cb-multios,代码行数:52,代码来源:service.c
示例7: main
int
main(int argc, char *argv[])
{
int i;
if (argc <= 0 || !argv[0]) {
fprintf(stderr, "invalid program name\n");
return 1;
}
program_name = os_GetLastname(argv[0]);
get_program_dir(argv[0]);
for (i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "--version")) {
print_version();
} else if (!strcmp(argv[i], "--help")) {
print_help();
} else {
die("invalid option: %s", argv[i]);
}
}
get_config_file();
parse_config();
create_dir();
do_loop();
return 0;
}
开发者ID:mezun7,项目名称:ejudge,代码行数:29,代码来源:nwrun.c
示例8: copy_file_to_file
int64_t copy_file_to_file(const char *input, const char *output)
{
int in = open(input, O_RDONLY);
if (in == -1)
return -1;
struct stat info;
if (fstat(in, &info) == -1) {
close(in);
return -1;
}
int out = open(output, O_WRONLY|O_CREAT|O_TRUNC, info.st_mode);
if (out == -1 && errno == ENOTDIR) {
char dir[PATH_MAX];
path_dirname(output, dir);
if (create_dir(dir, S_IRWXU)) {
out = open(output, O_WRONLY|O_CREAT|O_TRUNC, info.st_mode);
}
}
if (out == -1) {
close(in);
return -1;
}
int64_t total = copy_fd_to_fd(in, out);
close(in);
close(out);
return total;
}
开发者ID:LydiaBrothers,项目名称:cctools,代码行数:32,代码来源:copy_stream.c
示例9: main
int
main(int argc, char **argv)
{
pid_t pid[32], p;
int i;
uint64_t start, end, usec;
printf("Create directories...\n");
start = read_tsc();
create_dir(PATH_PREFIX);
for (i = 0; i < nr_threads; i++) {
p = fork();
if (p == 0) {
worker((void *) (long) i);
exit(0);
}
pid[i] = p;
}
for (i = 0; i < nr_threads; i++) {
waitpid(pid[i], NULL, 0);
}
end = read_tsc();
usec = (end - start) * 1000000 / get_cpu_freq();
printf("usec: %ld\t\n", usec);
printf("Cleanup directories...\n");
/* system("rm -rf /tmp/_dirs"); */
return 0;
}
开发者ID:rousya,项目名称:linux-scalability-benchmark,代码行数:32,代码来源:dirmaker_fork.c
示例10: create_dir
/* Create a directory, including parent directories as necessary. */
void
create_dir(char *pathname, int mode)
{
if (pathname != NULL) {
char *p;
int r;
/* Strip trailing '/' */
if (pathname[strlen(pathname) - 1] == '/')
pathname[strlen(pathname) - 1] = '\0';
/* Try creating the directory. */
r = mkdir(pathname, mode);
if (r != 0 && errno != EEXIST) {
/* On failure, try creating parent directory. */
p = strrchr(pathname, '/');
if (p != NULL) {
*p = '\0';
create_dir(pathname, 0755);
*p = '/';
r = mkdir(pathname, mode);
}
}
if (r != 0 && errno != EEXIST)
fprintf(stderr, "ERROR CREATING DIRECTORY %s\n", pathname);
}
}
开发者ID:3sidedcube,项目名称:iOS-ThunderCloud,代码行数:31,代码来源:untar.c
示例11: main
int main (int argc, char **argv)
{
char * out_dir;
char out_file[128];
int i;
seek_table_type table;
fas_error_type video_error;
fas_context_ref_type context, seek_context;
cmdname = argv[0];
if (argc < 3) {
show_help();
fail("arguments\n");
}
table = read_table_file(argv[2]);
if (table.num_entries == 0)
fail("bad table\n");
fas_initialize (FAS_FALSE, FAS_RGB24);
video_error = fas_open_video (&context, argv[1]);
if (video_error != FAS_SUCCESS) fail("fail on open\n");
video_error = fas_put_seek_table(context, table);
if (video_error != FAS_SUCCESS) fail("fail on put_seek_table\n");
video_error = fas_open_video (&seek_context, argv[1]);
if (video_error != FAS_SUCCESS) fail("fail on open\n");
if (argc >= 4) {
out_dir = argv[3];
create_dir(out_dir);
} else {
out_dir = ".";
}
for(i=0;i<table.num_entries;i++)
{
fas_raw_image_type image_buffer;
// int frame_index = table.array[table.num_entries - i - 1].display_index;
int frame_index = table.array[i].display_index;
if (FAS_SUCCESS != fas_seek_to_frame(context, frame_index))
fail("failed on seek");
if (FAS_SUCCESS != fas_get_frame (context, &image_buffer))
fail("failed on rgb image\n");
sprintf(out_file, "%s/frame_%04d.ppm", out_dir, frame_index);
fprintf(stderr, "Writing %s (seek_table_value=%d frame_index=%d)\n", out_file, frame_index, fas_get_frame_index(context));
ppm_save(&image_buffer, out_file);
fas_free_frame (image_buffer);
}
success();
}
开发者ID:AMDmi3,项目名称:ffmpeg-fas,代码行数:60,代码来源:dump_keyframes.c
示例12: readFileList
int readFileList(char *basePath, int dir_id) {
DIR *dir;
struct dirent *ptr;
char base[1000];
if ((dir=opendir(basePath)) == NULL) {
return 0;
}
while ((ptr=readdir(dir)) != NULL) {
if(strcmp(ptr->d_name,".")==0 || strcmp(ptr->d_name,"..")==0) //current dir OR parrent dir
continue;
memset(base,'\0',sizeof(base));
strcpy(base,basePath);
strcat(base,"/");
strcat(base,ptr->d_name);
if(ptr->d_type == 8) { //file
create_file(base, dir_id);
// printf("%s/%s : %lld %ld\n",basePath, ptr->d_name, size, ptr->d_ino);
}
else if(ptr->d_type == 4) { //dir
dir_tot ++;
int tmp = readFileList(base, dir_tot);
strcpy(d[dir_id].entry[c[dir_id]].filename, ptr->d_name);
d[dir_id].entry[c[dir_id]].inode_off = tot;
c[dir_id] ++;
create_dir(tmp);
}
}
closedir(dir);
return dir_id;
}
开发者ID:akuxcw,项目名称:oslab2016,代码行数:34,代码来源:format.c
示例13: init
static int init() {
struct stat fstatus;
struct group *group;
cp_string logfile;
_set_defaults();
umask(0077);
group=getgrnam(conf.grp);
if (group) {
setgid(group->gr_gid);
log_event(CPDEBUG, "switching to new gid", conf.grp);
} else {
log_event(CPERROR, "Grp not found", conf.grp);
return 1;
}
/* we always use a log file */
if (stat(conf.log, &fstatus) || !S_ISDIR(fstatus.st_mode)) {
if (create_dir(conf.log, 1))
return 1;
if (chmod(conf.log, 0700))
return 1;
}
snprintf(logfile,BUFSIZE,"%s%s",conf.log,"/pdfwriter_log");
logfp=fopen(logfile, "a");
return 0;
}
开发者ID:erikdejonge,项目名称:printer_osx_pdf,代码行数:31,代码来源:pdfwriter.c
示例14: batch_submit
static int batch_submit( void * instance_struct, struct batch_task *t){
struct archive_instance *a = (struct archive_instance*)instance_struct;
int rc = MAKEFLOW_HOOK_SUCCESS;
// Generates a hash id for the task
char *id = batch_task_generate_id(t);
char *task_path = string_format("%s/tasks/%.2s/%s",a->dir, id, id);
create_dir(task_path,0777);
debug(D_MAKEFLOW_HOOK, "Checking archive for task %d at %.5s\n", t->taskid, id);
if(a->s3){
int result = 1;
result = makeflow_s3_archive_copy_task_files(a, id, task_path, t);
if(!result){
debug(D_MAKEFLOW_HOOK, "unable to copy task files for task %s from S3 bucket",id);
}
}
// If a is in read mode and the archive is preserved (all the output files exist)
if(a->read && makeflow_archive_is_preserved(a, t, task_path)){
debug(D_MAKEFLOW_HOOK, "Task %d already exists in archive, replicating output files\n", t->taskid);
/* copy archived files to working directory and update state for node and dag_files */
makeflow_archive_copy_preserved_files(a, t, task_path);
t->info->exited_normally = 1;
a->found_archived_job = 1;
printf("task %d was pulled from archive\n", t->taskid);
rc = MAKEFLOW_HOOK_SKIP;
}
free(id);
free(task_path);
return rc;
}
开发者ID:Nekel-Seyew,项目名称:cctools,代码行数:33,代码来源:makeflow_module_archive.c
示例15: create_dir
/* Create a directory, including parent directories as necessary. */
static void
create_dir(char *pathname, int mode)
{
char *p;
int r;
/* Strip trailing '/' */
if (pathname[strlen(pathname) - 1] == '/')
pathname[strlen(pathname) - 1] = '\0';
/* Try creating the directory. */
r = mkdir(pathname, mode);
if (r != 0) {
/* On failure, try creating parent directory. */
p = strrchr(pathname, '/');
if (p != NULL) {
*p = '\0';
create_dir(pathname, 0755);
*p = '/';
r = mkdir(pathname, mode);
}
}
if (r != 0)
fprintf(stderr, "Could not create directory %s\n", pathname);
}
开发者ID:gianluca-nitti,项目名称:nw.js-global-install,代码行数:27,代码来源:untar.c
示例16: create_dir
static int create_dir(char *dirname, int nolog) {
struct stat fstatus;
char buffer[BUFSIZE],*delim;
int i;
while ((i=strlen(dirname))>1 && dirname[i-1]=='/')
dirname[i-1]='\0';
if (stat(dirname, &fstatus) || !S_ISDIR(fstatus.st_mode)) {
strncpy(buffer,dirname,BUFSIZE);
delim=strrchr(buffer,'/');
if (delim!=buffer)
delim[0]='\0';
else
delim[1]='\0';
if (create_dir(buffer,nolog)!=0)
return 1;
stat(buffer, &fstatus);
if (mkdir(dirname,fstatus.st_mode)!=0) {
if (!nolog)
log_event(CPERROR, "failed to create directory", dirname);
return 1;
}
else
if (!nolog)
log_event(CPSTATUS, "directory created", dirname);
if (chown(dirname,fstatus.st_uid,fstatus.st_gid)!=0)
if (!nolog)
log_event(CPDEBUG, "failed to set owner on directory (non fatal)", dirname);
}
return 0;
}
开发者ID:erikdejonge,项目名称:printer_osx_pdf,代码行数:31,代码来源:pdfwriter.c
示例17: main
int main(void)
{
int x;
while(TRUE)
{
x=menu(x);
switch(x)
{
case 0:
return 0;
case 1:
create_dir();break;
case 2:
find_dir();break;
case 3:
del_dir();break;
case 4:
modify_dir();break;
case 5:
insert_dir();break;
case 6:
num();break;
case 7:
all();break;
default:
exit(-1);
}
}
return 0;
}
开发者ID:Wangyao14cyy,项目名称:Documents-backup,代码行数:30,代码来源:未完成.cpp
示例18: scrolltext_extract
bool
scrolltext_extract (void)
{
Uint32 i;
const char *model = EXPORT_DIR "/scrolltext/char-xx.png";
char *filename = memory_allocation (strlen (model) + 1);
if (filename == NULL)
{
LOG_ERR ("not enough memory to allocate %i bytes\n",
(Uint32) (strlen (model) + 1));
return FALSE;
}
if (!create_dir (EXPORT_DIR "/scrolltext"))
{
free_memory (filename);
return FALSE;
}
for (i = 0; i < FONT_SCROLLTEXT_MAXOF_GLYPHS; i++)
{
sprintf (filename, EXPORT_DIR "/scrolltext/char-%02d.png", i);
if (!bitmap_to_png (&fnt_scroll[i], filename, 20, 21, offscreen_pitch))
{
free_memory (filename);
return FALSE;
}
}
free_memory (filename);
return TRUE;
}
开发者ID:netmask,项目名称:powermanga,代码行数:29,代码来源:scrolltext.c
示例19: create_dir
int
create_dir (char *path)
{
char *parent;
char *tmp;
int rc;
tmp = strdup (path); /* preserve our string */
parent = dirname (tmp);
rc = check_dir (parent);
if (strcmp (parent, "/") == 0)
{
return -1; /* stop endless loop */
}
if (rc == MISC_NOT_DIR || rc == MISC_NOT_WRITABLE)
{
return -1;
}
else if (rc == MISC_DOES_NOT_EXISTS)
{
/* recursively create */
if (create_dir (parent) != 0)
{
fprintf (stderr, "failed to create %s\n", parent);
return -1;
}
}
rc = mkdir (path, 0755);
free (tmp);
return rc;
}
开发者ID:alip2890,项目名称:Rippix,代码行数:31,代码来源:misc_utils.c
示例20: create_task_directories
// return 0 on error, 1 otherwise
static int create_task_directories(struct work_queue_process *p) {
char tmpdir_template[1024];
p->sandbox = string_format("t.%d", p->task->taskid);
if(!create_dir(p->sandbox, 0777)) {
return 0;
}
char absolute[1024];
path_absolute(p->sandbox, absolute, 1);
free(p->sandbox);
p->sandbox = xxstrdup(absolute);
sprintf(tmpdir_template, "%s/cctools-temp-t.%d.XXXXXX", p->sandbox, p->task->taskid);
if(mkdtemp(tmpdir_template) == NULL) {
return 0;
}
p->tmpdir = xxstrdup(tmpdir_template);
if(chmod(p->tmpdir, 0777) != 0) {
return 0;
}
return 1;
}
开发者ID:Baguage,项目名称:cctools,代码行数:26,代码来源:work_queue_process.c
注:本文中的create_dir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论