本文整理汇总了C++中dir_exists函数的典型用法代码示例。如果您正苦于以下问题:C++ dir_exists函数的具体用法?C++ dir_exists怎么用?C++ dir_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dir_exists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: RecurseCreateDirectory
/// 需要移动到公共目录下,递归创建目录
static int RecurseCreateDirectory(const char *dir)
{
if( dir[0] == 0 )
return DDCE_ARGUMENT_ERROR;
DDC_BOOL_RETURN( dir_exists(dir),DDCE_SUCCESS );
char dirFather[MAX_PATH*2];
strncpy(dirFather,dir,MAX_PATH*2);
char *p = strrchr(dirFather,DDC_C_SLASH);
if( p )
*p = 0;
while( !dir_exists(dirFather) )
{
int ret = RecurseCreateDirectory(dirFather);
if( ret != 0 )
return ret;
}
//目录结尾不带"\\"
if( dir[strlen(dir)-1] != DDC_C_SLASH )
return CreateDirectory(dir,NULL)==TRUE?0:DDCE_DISK_OP_ERROR;
return 0;
}
开发者ID:cugxiangzhenwei,项目名称:TSP_Zhenwei,代码行数:27,代码来源:PluginManager.cpp
示例2: worldStorePersistentRoom
//
// store a room in the persistent database
void worldStorePersistentRoom(WORLD_DATA *world, const char *key,
ROOM_DATA *room) {
static char fname[MAX_BUFFER];
static char dir1[SMALL_BUFFER];
static char dir2[SMALL_BUFFER];
if(!*key)
return;
unsigned long hash1 = pearson_hash8_1(key) % WORLD_BINS;
unsigned long hash2 = pearson_hash8_2(key) % WORLD_BINS;
*fname = '\0';
*dir1 = '\0';
*dir2 = '\0';
// make sure our hash bins exist
sprintf(dir1, "%s/persistent/%lu",
worldGetPath(world), hash1);
if(!dir_exists(dir1))
mkdir(dir1, S_IRWXU | S_IRWXG);
// and the second one as well
sprintf(dir2, "%s/persistent/%lu/%lu",
worldGetPath(world), hash1, hash2);
if(!dir_exists(dir2))
mkdir(dir2, S_IRWXU | S_IRWXG);
// now, store the room
sprintf(fname, "%s/persistent/%lu/%lu/%s",
worldGetPath(world), hash1, hash2, key);
STORAGE_SET *set = roomStore(room);
storage_write(set, fname);
storage_close(set);
// log_string("stored persistent room :: %s", fname);
}
开发者ID:KaSt,项目名称:nereamud,代码行数:37,代码来源:persistent.c
示例3: rmkdir
static int rmkdir(char* path) {
/*
* strip off trailing components unless we can stat the directory, or we
* have run out of components
*/
char* i = strrchr(path, '/');
if (path[0] == '\0' || dir_exists(path))
return 0;
if (i != NULL) {
*i = '\0';
rmkdir(path);
*i = '/';
mkdir(path, 0777);
}
#ifdef WIN32
return 0;
#else
if (dir_exists(path))
return 0;
else
return -1;
#endif
}
开发者ID:NSGod,项目名称:chmlib,代码行数:27,代码来源:extract.c
示例4: cgm_mount_cgroup
static bool cgm_mount_cgroup(void *hdata, const char *root, int type)
{
if (dir_exists(CGMANAGER_LOWER_SOCK))
return cgm_bind_dir(root, CGMANAGER_LOWER_SOCK);
if (dir_exists(CGMANAGER_UPPER_SOCK))
return cgm_bind_dir(root, CGMANAGER_UPPER_SOCK);
// Host doesn't have cgmanager running? Then how did we get here?
return false;
}
开发者ID:JedMeister,项目名称:jessie-lxc-dev,代码行数:9,代码来源:cgmanager.c
示例5:
bool
Setup::createDirIfNeeded(const char *path, int mode)
{
if (!dir_exists(path))
{
if (makedirs(path, mode) != 0 || !dir_exists(path))
{
fprintf(stderr, "failed to create missing directory: %s\n", path);
return false;
}
}
return true;
}
开发者ID:rallan9,项目名称:inetfs,代码行数:13,代码来源:Setup.cpp
示例6: initialize_catalog
static int initialize_catalog(void)
{
if (!initialized)
{
bool default_dir = true;
/* directory config is of the format: "dir: /path/to/dir" */
if (global_settings.playlist_catalog_dir[0] &&
strcmp(global_settings.playlist_catalog_dir,
PLAYLIST_CATALOG_DEFAULT_DIR))
{
strcpy(playlist_dir, global_settings.playlist_catalog_dir);
default_dir = false;
}
/* fall back to default directory if no or invalid config */
if (default_dir)
{
strcpy(playlist_dir, PLAYLIST_CATALOG_DEFAULT_DIR);
if (!dir_exists(playlist_dir))
mkdir(playlist_dir);
}
playlist_dir_length = strlen(playlist_dir);
if (dir_exists(playlist_dir))
{
playlist_dir_exists = true;
memset(most_recent_playlist, 0, sizeof(most_recent_playlist));
initialized = true;
}
}
if (!playlist_dir_exists)
{
if (mkdir(playlist_dir) < 0) {
splashf(HZ*2, ID2P(LANG_CATALOG_NO_DIRECTORY), playlist_dir);
return -1;
}
else {
playlist_dir_exists = true;
memset(most_recent_playlist, 0, sizeof(most_recent_playlist));
initialized = true;
}
}
return 0;
}
开发者ID:victor2002,项目名称:rockbox_victor_clipplus,代码行数:49,代码来源:playlist_catalog.c
示例7: FilterSession
CacheSession::CacheSession(ClientSession *session, const char *url, uint32_t file_ttl,
uint32_t dir_ttl)
: FilterSession(session)
{
m_dir_ttl = file_ttl;
m_dir_ttl = dir_ttl;
string tmp(url);
make_hash64("md5", tmp, m_url_hash, true);
tmp = url + string(":meta:") + get_client_id();
make_hash64("md5", tmp, m_meta_key, true);
tmp = url + string(":data:") + get_client_id();
make_hash64("md5", tmp, m_data_key, true);
m_base_dir = cacheBaseDir() + SEPSTR + m_url_hash;
if (!dir_exists(m_base_dir.c_str()) && makedirs(m_base_dir.c_str()) < 0)
{
m_enable = false;
_DEBUG("Disabling Cache Session: can't create");
}
#if 0
else if (!can_write_dir(m_base_dir.c_str()))
{
m_enable = false;
_DEBUG("Disabling Cache Session: can't write");
}
#endif
else
{
m_enable = true;
_DEBUG("Enabling Cache Session");
}
}
开发者ID:rallan9,项目名称:inetfs,代码行数:31,代码来源:CacheSession.cpp
示例8: cgm_bind_dir
static bool cgm_bind_dir(const char *root, const char *dirname)
{
nih_local char *cgpath = NULL;
/* /sys should have been mounted by now */
cgpath = NIH_MUST( nih_strdup(NULL, root) );
NIH_MUST( nih_strcat(&cgpath, NULL, "/sys/fs/cgroup") );
if (!dir_exists(cgpath)) {
ERROR("%s does not exist", cgpath);
return false;
}
/* mount a tmpfs there so we can create subdirs */
if (mount("cgroup", cgpath, "tmpfs", 0, "size=10000,mode=755")) {
SYSERROR("Failed to mount tmpfs at %s", cgpath);
return false;
}
NIH_MUST( nih_strcat(&cgpath, NULL, "/cgmanager") );
if (mkdir(cgpath, 0755) < 0) {
SYSERROR("Failed to create %s", cgpath);
return false;
}
if (mount(dirname, cgpath, "none", MS_BIND, 0)) {
SYSERROR("Failed to bind mount %s to %s", dirname, cgpath);
return false;
}
return true;
}
开发者ID:JedMeister,项目名称:jessie-lxc-dev,代码行数:32,代码来源:cgmanager.c
示例9: setup_cgroup_dir
/*
* We may decide to make the socket path customizable. For now
* just assume it is in /sys/fs/cgroup/ which has some special
* consequences
*/
static bool setup_cgroup_dir(void)
{
int ret;
if (!dir_exists(CGDIR)) {
nih_debug(CGDIR " does not exist");
return false;
}
if (daemon_running()) {
nih_error("%s: cgmanager is already running", __func__);
return false;
}
if (file_exists(CGMANAGER_SOCK)) {
if (unlink(CGMANAGER_SOCK) < 0) {
nih_error("%s: failed to delete stale cgmanager socket", __func__);
return false;
}
}
/* Check that /sys/fs/cgroup is writeable, else mount a tmpfs */
unlink(CGPROBE);
ret = creat(CGPROBE, O_RDWR);
if (ret >= 0) {
close(ret);
unlink(CGPROBE);
return mkdir_cgmanager_dir();
}
ret = mount("cgroup", CGDIR, "tmpfs", 0, "size=10000");
if (ret) {
nih_debug("Failed to mount tmpfs on %s: %s",
CGDIR, strerror(errno));
return false;
}
nih_debug("Mounted tmpfs onto %s", CGDIR);
return mkdir_cgmanager_dir();
}
开发者ID:renaldy84,项目名称:cgmanager,代码行数:39,代码来源:cgmanager.c
示例10: spray
void spray(int s, const struct sockaddr *cli, int cli_len,
const char *file_path, __u16 padding, unsigned int fr)
{
char *filename = basename(file_path);
char *encoded_file_path;
int size;
int num_blocks;
size = asprintf(&encoded_file_path, "%s/%s", ENCODED_DIR, filename);
if (size == -1) {
fprintf(stderr,
"asprintf: cannot allocate encoded file path\n");
return;
}
/* Check if a directory for that name exists. */
if (!dir_exists(encoded_file_path)) {
fprintf(stderr,
"invalid request; %s encoding does not exist\n",
filename);
return;
}
num_blocks = get_num_blocks(filename);
if (num_blocks == -1) {
fprintf(stderr,
"get_num_blocks: cannot find number of blocks\n");
return;
}
send_data_files(s, cli, cli_len, filename, num_blocks, padding, fr);
send_code_files(s, cli, cli_len, filename, num_blocks, padding, fr);
}
开发者ID:cjdoucette,项目名称:fountain,代码行数:33,代码来源:spray.c
示例11: recursive_remove
static int recursive_remove(const char * const path) {
if (NULL == path) { return 0; }
int e = 0;
if (dir_exists(path)) {
FTSENT * ent;
const char * const ptrs[] = { path, 0 };
const int fts_options = FTS_NOCHDIR | FTS_PHYSICAL | FTS_XDEV;
FTS * fts = fts_open((char * const *)ptrs, fts_options, NULL);
while((ent = fts_read(fts)) && 0 == e) {
switch(ent->fts_info) {
case FTS_NS: case FTS_DNR: case FTS_ERR:
fprintf(stderr, "%s: fts_read error: %s\n",
ent->fts_accpath, strerror(ent->fts_errno));
e = ent->fts_errno;
break;
case FTS_D: case FTS_DC: case FTS_DOT: case FTS_NSOK:
break;
case FTS_DP: case FTS_F: case FTS_SL: case FTS_SLNONE: case FTS_DEFAULT:
if (0 != remove(ent->fts_accpath)) {
fprintf(stderr, "Unable to remove %s. %s\n",
ent->fts_accpath,
strerror(ent->fts_errno));
e = ent->fts_errno;
}
break;
}
}
fts_close(fts);
}
return e;
}
开发者ID:sw17ch,项目名称:triefort,代码行数:35,代码来源:triefort.c
示例12: make_dir
/*-------------------------------------------------------------------------*/
int make_dir(char *path) {
int i;
char tmp_path1[MAXPATH],
tmp_path2[MAXPATH],
length,
mkdir_error;
if (path[0] == '\0') {
return -1;
}
strmcpy(tmp_path1, path, sizeof(tmp_path1));
cat_separator(tmp_path1);
length = strlen(tmp_path1);
strncpy(tmp_path2, tmp_path1, 3);
i = 3;
while (i < length) {
if (tmp_path1[i] == '\\') {
tmp_path2[i] = '\0';
if (!dir_exists(tmp_path2)) {
mkdir_error = mkdir(tmp_path2);
if (mkdir_error) {
path[i] = '\0';
return mkdir_error;
}
}
}
tmp_path2[i] = tmp_path1[i];
i++;
}
return 0;
}
开发者ID:FDOS,项目名称:xcopy,代码行数:36,代码来源:xcopy.c
示例13: dispatch
int dispatch(const avector * vec, const long const * lows, const long const * highs, const int num_ranges,
const double d, const long lo, const long hi, const char * destdir, const char * fprefix)
{
// group file names: destdir/fprefix_g<rid>_d_lo_hi
#define BASENAME_LEN 40
char vecgroupname[FILENAME_MAX];
char * psuffix, *pslash;
int rid, rcounter = 0;
bool last_range = FALSE;
assert( vec!=NULL );
assert( destdir!=NULL );
if ( ! dir_exists(destdir) ) {
fprintf(stderr, "ERROR: directory does not exist: %s\n", destdir);
return 0;
}
if ( vec->size<=0 )
return 0;
/* prepare for the group names: */
strncpy(vecgroupname, destdir, FILENAME_MAX);
vecgroupname[FILENAME_MAX-1] = 0;
psuffix = vecgroupname + strlen(vecgroupname);
assert( psuffix>vecgroupname );
assert( psuffix-vecgroupname < FILENAME_MAX-BASENAME_LEN ); // save space for actual names.
pslash = strrchr(vecgroupname, '/');
if ( pslash==NULL || pslash+1!=psuffix )
*psuffix++ = '/';
*psuffix = 0;
for ( rid=0; rid<num_ranges; rid++ ) {
if ( vec->size < lows[rid] )
break;
else if ( vec->size <= highs[rid] || highs[rid]<0 ) {
// save the vector into this range:
FILE * vgfile = NULL;
snprintf(psuffix, BASENAME_LEN, "%s_g%d_%.8g_%ld_%ld", fprefix, rid+1, d, lo, hi);
vgfile = fopen(vecgroupname, "a"); // NOTE: old group files are kept.
if ( vgfile == NULL ) {
fprintf(stderr, "Can't append to vector group file '%s'\n", vecgroupname);
continue;
}
outputavector(vgfile, vec, 0);
fclose(vgfile);
rcounter++;
if ( highs[rid]<0 ) {
if ( last_range )
fprintf(stderr, "WARN: more than one -1 in the ranges; current rid = %d\n", rid+1);
last_range = TRUE;
}
} else
continue;
}
return rcounter;
}
开发者ID:HelloWorld017,项目名称:safe,代码行数:59,代码来源:dispatchvectors.c
示例14: run_uninstall_autoloader
int run_uninstall_autoloader()
{
#ifdef ENABLE_LOG
if (verbose) WriteToLog("[UNINSTALLER]");
#endif
//Check if installed
if(file_exists("/dev_flash/sys/internal/sys_init_osd_orig.self") != SUCCESS)
{
#ifdef ENABLE_LOG
if (verbose) WriteToLog("Error: sys_init_osd_orig.self not found\r\n");
#endif
return FAILED;
}
//Enable dev_blind
if(dir_exists("/dev_blind") != SUCCESS)
{
{lv2syscall8(SC_FS_MOUNT, (u64)(char*)"CELL_FS_IOS:BUILTIN_FLSH1", (u64)(char*)"CELL_FS_FAT", (u64)(char*)"/dev_blind", 0, 0, 0, 0, 0); }
}
//Restore original sys_init_osd.self
if(file_exists(PATH_SYS_INI_OSD_ORIG) == SUCCESS)
{
if(file_exists(PATH_SYS_INI_OSD) == SUCCESS)
{
unlink_secure(PATH_SYS_INI_OSD);
sysLv2FsRename(PATH_SYS_INI_OSD_ORIG, PATH_SYS_INI_OSD);
//Remove payload
char filename[128];
int fw_list[32] = { 0x355C,0x421C,0x430C,0x431C,0x440C,0x441C,0x446C,0x450C,0x453C,0x455C,0x460C,0x465C,0x466C,0x470C,0x475C,0x476C,
0x355D,0x421D,0x430D, 0x441D,0x446D,0x450D,0x453D,0x455D,0x460D,0x465D,0x466D,0x470D,0x475D,0x476D};
int i;
for (i = 0; i < 32; i++)
{
if (fw_list[i] == 0) break;
sprintf (filename, "/dev_blind/sys/internal/mpl_payload_%X.bin", fw_list[i]);
if (file_exists(filename) == SUCCESS) unlink_secure(filename);
sprintf (filename, "/dev_blind/sys/internal/mamba_%X.bin", fw_list[i]);
if (file_exists(filename) == SUCCESS) unlink_secure(filename);
}
#ifdef ENABLE_LOG
if (verbose) WriteToLog("Success: MAMBA/PRX Autoloader uninstalled\r\n");
#endif
return SUCCESS;
}
else
{
#ifdef ENABLE_LOG
if (verbose) WriteToLog("Error: sys_init_osd.self not found\r\n");
#endif
return FAILED;
}
}
else
{
#ifdef ENABLE_LOG
if (verbose) WriteToLog("Error: /dev_blind not mounted\r\n");
#endif
return FAILED;
}
}
开发者ID:TyrfingMjolnir,项目名称:MAMBA_PRX_Loader,代码行数:59,代码来源:main.c
示例15: GetFullPath
bool DirectoryIterator::IsDirectory()
{
char dtmp[_MAX_PATH];
GetFullPath(dtmp);
//this is needed on windows!!!
FixPath(dtmp, false);
return dir_exists(dtmp);
}
开发者ID:scriptedfate,项目名称:gemrb,代码行数:8,代码来源:VFS.cpp
示例16: START_TEST
END_TEST
START_TEST (dir_exists_test) {
int res;
const char *path;
res = dir_exists(NULL);
fail_unless(res == FALSE, "Failed to handle null arguments");
path = "/";
res = dir_exists(path);
fail_unless(res == TRUE, "Expected TRUE for path '%s', got FALSE", path);
path = "./api-tests";
res = dir_exists(path);
fail_unless(res == FALSE, "Expected FALSE for path '%s', got TRUE", path);
}
开发者ID:predever,项目名称:proftpd,代码行数:17,代码来源:misc.c
示例17: setup_proc
void setup_proc()
{
if(!dir_exists("/proc"))
mkdir("/proc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
int x = mount(NULL, "/proc", "proc", 0, NULL);
if(x != 0)
fatal(-1, true, "mount proc failed");
}
开发者ID:knusbaum,项目名称:spawnroot,代码行数:9,代码来源:mountutils.c
示例18: populate_tool_ctx
static rc_t populate_tool_ctx( tool_ctx_t * tool_ctx, const Args * args )
{
rc_t rc = ArgsParamValue( args, 0, ( const void ** )&( tool_ctx -> accession_path ) );
if ( rc != 0 )
ErrMsg( "ArgsParamValue() -> %R", rc );
else
{
tool_ctx -> lookup_filename[ 0 ] = 0;
tool_ctx -> index_filename[ 0 ] = 0;
tool_ctx -> dflt_output[ 0 ] = 0;
get_user_input( tool_ctx, args );
encforce_constrains( tool_ctx );
get_environment( tool_ctx );
rc = make_temp_dir( &tool_ctx -> temp_dir,
tool_ctx -> requested_temp_path,
tool_ctx -> dir );
}
if ( rc == 0 )
rc = handle_accession( tool_ctx );
if ( rc == 0 )
rc = handle_lookup_path( tool_ctx );
if ( rc == 0 && tool_ctx -> output_dirname != NULL )
{
if ( !dir_exists( tool_ctx -> dir, "%s", tool_ctx -> output_dirname ) )
rc = create_this_dir_2( tool_ctx -> dir, tool_ctx -> output_dirname, true );
}
if ( rc == 0 )
{
if ( tool_ctx -> output_filename == NULL )
{
if ( tool_ctx -> output_dirname == NULL )
rc = make_output_filename_from_accession( tool_ctx );
else
rc = make_output_filename_from_dir_and_accession( tool_ctx );
}
else
{
if ( tool_ctx -> output_dirname == NULL )
rc = adjust_output_filename( tool_ctx );
else
rc = adjust_output_filename_by_dir( tool_ctx );
}
}
if ( rc == 0 )
rc = Make_FastDump_Cleanup_Task ( &( tool_ctx -> cleanup_task ) ); /* cleanup_task.c */
if ( rc == 0 )
rc = Add_Directory_to_Cleanup_Task ( tool_ctx -> cleanup_task,
get_temp_dir( tool_ctx -> temp_dir ) );
return rc;
}
开发者ID:ncbi,项目名称:sra-tools,代码行数:57,代码来源:fasterq-dump.c
示例19: dir_create
bool dir_create(const std::string& path, const std::string& outdir) {
//std::string newpath = path + outdir;
boost::filesystem::path p(path.c_str());
boost::filesystem::path f(outdir.c_str());
boost::filesystem::path r = p / f;
std::string newpath = r.generic_string();
if (!dir_exists(newpath))
return fsnsp::create_directory(fsnsp::path(newpath.c_str()));
return true;
}
开发者ID:sealeks,项目名称:boost-itu-t,代码行数:10,代码来源:parser.cpp
示例20: dir_create
bool dir_create(const char *path)
{
const char *ptr;
char buf[512];
/* If the directory already exists then we're done */
if (dir_exists(path)) return TRUE;
#ifdef WINDOWS
/* If we're on windows, we need to skip past the "C:" part. */
if (isalpha(path[0]) && path[1] == ':') path += 2;
#endif
/* Iterate through the path looking for path segements. At each step,
* create the path segment if it doesn't already exist. */
for (ptr = path; *ptr; ptr++)
{
if (*ptr == PATH_SEPC)
{
/* Find the length of the parent path string */
size_t len = (size_t)(ptr - path);
/* Skip the initial slash */
if (len == 0) continue;
/* If this is a duplicate path separator, continue */
if (*(ptr - 1) == PATH_SEPC) continue;
/* We can't handle really big filenames */
if (len - 1 > 512) return FALSE;
/* Create the parent path string, plus null-padding */
my_strcpy(buf, path, len + 1);
/* Skip if the parent exists */
if (dir_exists(buf)) continue;
/* The parent doesn't exist, so create it or fail */
if (my_mkdir(buf, 0755) != 0) return FALSE;
}
}
return my_mkdir(path, 0755) == 0 ? TRUE : FALSE;
}
开发者ID:cinereaste,项目名称:angband,代码行数:43,代码来源:z-file.c
注:本文中的dir_exists函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论