コード例 #1
0
ファイル: c_dir.c プロジェクト: valarauco/galletica
int c_mkdirs(const char *path, mode_t mode) {
  int tmp;
  csync_stat_t sb;
  const _TCHAR *wpath = c_multibyte(path);
  const _TCHAR *swpath = NULL;
  
  if (path == NULL) {
    errno = EINVAL;
    return -1;
  }

  if (_tstat(wpath, &sb) == 0) {
    if (! S_ISDIR(sb.st_mode)) {
      errno = ENOTDIR;
      return -1;
    }
  }
  
  tmp = strlen(path);
  while(tmp > 0 && path[tmp - 1] == '/') --tmp;
  while(tmp > 0 && path[tmp - 1] != '/') --tmp;
  while(tmp > 0 && path[tmp - 1] == '/') --tmp;

  if (tmp > 0) {
    char subpath[tmp + 1];
    memcpy(subpath, path, tmp);
    subpath[tmp] = '\0';
    swpath = c_multibyte(subpath);
    if (_tstat(swpath, &sb) == 0) {
      if (! S_ISDIR(sb.st_mode)) {
        errno = ENOTDIR;
        return -1;
      }
    } else if (errno != ENOENT) {
      c_free_multibyte(swpath);
      return -1;
    } else if (c_mkdirs(subpath, mode) < 0) {
      c_free_multibyte(swpath);
      return -1;
    }
  }
#ifdef _WIN32
  tmp = _tmkdir(wpath);
#else
  tmp = _tmkdir(wpath, mode);
#endif
  c_free_multibyte(swpath);
  c_free_multibyte(wpath);

  if ((tmp < 0) && (errno == EEXIST)) {
    return 0;
  }
  return tmp;
}
コード例 #2
0
CString sPicSavePath()
{
        CString sPath;
		sPath.Append(sAPPDATA());
		sPath.Append(_T("\\Acer\\clearfi\\MediaInfo")); 
		_tmkdir(sPath);		
		sPath.Append(_T("\\MediaThumbnail\\")); 
	    _tmkdir(sPath);
      
        return sPath;
   
}
コード例 #3
0
ファイル: check_vio_ext.c プロジェクト: Hopebaytech/client
/* This function takes a relative path, prepends it with the CSYNC_TEST_DIR
 * and creates each sub directory.
 */
static void create_dirs( const char *path )
{
  int rc;
  char *mypath = c_malloc( 2+strlen(CSYNC_TEST_DIR)+strlen(path));
  *mypath = '\0';
  strcat(mypath, CSYNC_TEST_DIR);
  strcat(mypath, "/");
  strcat(mypath, path);

  char *p = mypath+strlen(CSYNC_TEST_DIR)+1; /* start behind the offset */
  int i = 0;

  assert_non_null(path);

  while( *(p+i) ) {
    if( *(p+i) == '/' ) {
      p[i] = '\0';

      mbchar_t *mb_dir = c_utf8_path_to_locale(mypath);
      /* wprintf(L"OOOO %ls (%ld)\n", mb_dir, strlen(mypath)); */
      rc = _tmkdir(mb_dir, MKDIR_MASK);
      c_free_locale_string(mb_dir);

      assert_int_equal(rc, 0);
      p[i] = '/';
    }
    i++;
  }
  SAFE_FREE(mypath);
}
コード例 #4
0
ファイル: check_vio_ext.c プロジェクト: Hopebaytech/client
static void setup_testenv(void **state) {
    int rc;

    rc = wipe_testdir();
    assert_int_equal(rc, 0);

    mbchar_t *dir = c_utf8_path_to_locale(CSYNC_TEST_DIR);

    rc = _tmkdir(dir, MKDIR_MASK);
    assert_int_equal(rc, 0);

    assert_non_null(_tgetcwd(wd_buffer, WD_BUFFER_SIZE));

    rc = _tchdir(dir);
    assert_int_equal(rc, 0);

    c_free_locale_string(dir);

    /* --- initialize csync */
    statevar *mystate = malloc( sizeof(statevar) );
    mystate->result = NULL;

    csync_create(&(mystate->csync), "/tmp/csync1", "/tmp/csync2");

    mystate->csync->replica = LOCAL_REPLICA;

    *state = mystate;
}
コード例 #5
0
ファイル: mkdir.c プロジェクト: Caleb1994/stewieos-gcc
int
__gnat_mkdir (char *dir_name, int encoding ATTRIBUTE_UNUSED)
{
#if defined (__vxworks)

  /* Pretend that the system mkdir is posix compliant even though it
     sometimes is not, not expecting the second argument in some
     configurations (e.g. vxworks 653 2.2, difference from 2.5). The
     second actual argument will just be ignored in this case.  */

  typedef int posix_mkdir (const char * name, mode_t mode);

  posix_mkdir * vxmkdir = (posix_mkdir *)&mkdir;
  return vxmkdir (dir_name, S_IRWXU | S_IRWXG | S_IRWXO);

#elif defined (__MINGW32__)
  TCHAR wname [GNAT_MAX_PATH_LEN + 2];

  if (encoding == Encoding_Unspecified)
    S2WSC (wname, dir_name, GNAT_MAX_PATH_LEN);
  else if (encoding == Encoding_UTF8)
    S2WSU (wname, dir_name, GNAT_MAX_PATH_LEN);
  else
    S2WS (wname, dir_name, GNAT_MAX_PATH_LEN);

  return _tmkdir (wname);
#else
  return mkdir (dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
#endif
}
コード例 #6
0
ファイル: Properties.cpp プロジェクト: Robertysc/ecos
bool CProperties::CreatePathToFile(LPCTSTR pszDir) 
{
  // Create intermediate directories
#ifdef _WIN32
  const TCHAR cSep='\\';
#else // UNIX
  const TCHAR cSep='/';
#endif
  for(LPCTSTR c=_tcschr(pszDir,cSep);c;c=_tcschr(c+1,cSep)){
#ifdef _WIN32
    if(c==pszDir+2 && _istalpha(pszDir[0]) && _TCHAR(':')==pszDir[1]){
      continue; // don't attempt to create "C:"
    }
#endif
    String strDir(pszDir,c-pszDir);
    struct _stat buf;
    if(!(0==_tstat(strDir,&buf) && (S_IFDIR&buf.st_mode))){
      // Need to create directory
      bool b=(0==_tmkdir(strDir));
      TRACE(_T("Create directory %s rc=%d\n"),(LPCTSTR)strDir,b);
      if(!b){
        return false;
      }
    }
  }
  return true;
}
コード例 #7
0
ファイル: dir.cpp プロジェクト: ByteRisc/pwsafe
stringT pws_os::getuserprefsdir()
{
  /**
   * Returns LOCAL_APPDATA\PasswordSafe (or ...\PasswordSafeD)
   * (Creating if necessary)
   * If can't figure out LOCAL_APPDATA, then return an empty string
   * to have Windows punt to exec dir, which is the historical behaviour
   */
#ifndef _DEBUG
  const stringT sPWSDir(_T("\\PasswordSafe\\"));
#else
  const stringT sPWSDir(_T("\\PasswordSafeD\\"));
#endif

  stringT sDrive, sDir, sName, sExt, retval;

  pws_os::splitpath(getexecdir(), sDrive, sDir, sName, sExt);
  sDrive += _T("\\"); // Trailing slash required.

  const UINT uiDT = ::GetDriveType(sDrive.c_str());
  if (uiDT == DRIVE_FIXED || uiDT == DRIVE_REMOTE) {
    stringT sLocalAppDataPath;
    if (GetLocalDir(CSIDL_LOCAL_APPDATA, sLocalAppDataPath))
      retval = sLocalAppDataPath + sPWSDir;
    if (PathFileExists(retval.c_str()) == FALSE)
      if (_tmkdir(retval.c_str()) != 0)
        retval = _T(""); // couldn't create dir!?
  } else if (uiDT == DRIVE_REMOVABLE) {
    stringT::size_type index = sDir.rfind(_T("Program\\"));
    if (index != stringT::npos)
      retval = getexecdir().substr(0, getexecdir().length() - 8);
  }
  return retval;
}
コード例 #8
0
ファイル: dir.cpp プロジェクト: ByteRisc/pwsafe
stringT pws_os::getsafedir(void)
{
  stringT sDrive, sDir, sName, sExt, retval;

  pws_os::splitpath(getexecdir(), sDrive, sDir, sName, sExt);
  const stringT sDriveT = sDrive + _T("\\"); // Trailing slash required.

  const UINT uiDT = ::GetDriveType(sDriveT.c_str());
  if (uiDT == DRIVE_REMOVABLE) { 
    stringT::size_type index = sDir.rfind(_T("Program\\"));
    if (index != stringT::npos) {
      sDir.replace(index, 8, stringT(_T("Safes\\")));
      retval = sDrive + sDir;
      if (PathFileExists(retval.c_str()) == TRUE)
        return retval;
    }
  }
  stringT sLocalSafePath;
  if (GetLocalDir(CSIDL_PERSONAL, sLocalSafePath)) {
    retval = sLocalSafePath + _T("\\My Safes");
    if (PathFileExists(retval.c_str()) == FALSE)
      if (_tmkdir(retval.c_str()) != 0)
        retval = _T(""); // couldn't create dir!?
  }
  return retval;
}
コード例 #9
0
ファイル: check_vio.c プロジェクト: Gnostech/mirall
static void check_csync_vio_rename_dir(void **state)
{
    CSYNC *csync = *state;
    csync_stat_t sb;
    int rc;

    mbchar_t *dir = c_utf8_to_locale("test");
    mbchar_t *dir2 = c_utf8_to_locale("test2");

    assert_non_null(dir);
    assert_non_null(dir2);

    rc = _tmkdir(dir, MKDIR_MASK);
    assert_int_equal(rc, 0);

    rc = csync_vio_rename(csync, "test", "test2");
    assert_int_equal(rc, 0);


    rc = _tstat(dir2, &sb);
    assert_int_equal(rc, 0);

    c_free_locale_string(dir);
    c_free_locale_string(dir2);
}
コード例 #10
0
ファイル: hddstress.cpp プロジェクト: willmomo/ry2kojima
//-----------------------------------------------------------------------------
// プログラム スタート
//-----------------------------------------------------------------------------
int _tmain(int argc, TCHAR** argv) {
	_tsetlocale(LC_ALL, _T("japanese"));

	if (argc == 2) {
		cDrv = argv[1][0];
	}

	TCHAR stressPath[MAX_PATH];
	_stprintf(stressPath, _T("%c:\\__hddstress__"), cDrv);

	TCHAR readPath[MAX_PATH];
	_stprintf(readPath, _T("%c:\\"), cDrv);

	// Ctrl+C でしか止まりません。
	for (;;) {
		// ストレステスト用ファイルを作成するフォルダを準備
		_tmkdir(stressPath);

		// ストレステスト用のファイルを作成
		MakeAll(stressPath);

		// 全ファイルを読み込むテスト
		ReadAll(readPath);
		_putts(_T(""));
	}

	return 0;
}
コード例 #11
0
ファイル: XSystem - 복사본.cpp プロジェクト: xahgo/tama
// szPath를 만든다. 만약 상위폴더가 없다면 실패하며 MakeRecursiveDir을 사용해야 한다.
BOOL XSYSTEM::MakeDir( LPCTSTR szPath )
{
	TCHAR szBuff[ 1024 ];
	_tcscpy_s( szBuff, szPath );
	if( _tmkdir( szBuff ) == 0 )
		return TRUE;
	return FALSE;
}
コード例 #12
0
void CreateFolder(const KString& FolderName)
{
	if(_tmkdir(UnslashedFolderName(FolderName)) != 0 && errno != EEXIST)
	{
		INITIATE_DEFINED_FAILURE(	(KString)TEXT("Error creating folder \"") +
										FolderName +
										TEXT("\"."));
	}
}
コード例 #13
0
ファイル: c_dir.c プロジェクト: OpenDataSpace/ocsync
int c_mkdirs(const char *path, mode_t mode) {
  int tmp;
  csync_stat_t sb;
  mbchar_t *wpath = c_utf8_to_locale(path);
  mbchar_t *swpath = NULL;

  if (path == NULL) {
    errno = EINVAL;
    return -1;
  }

  if (_tstat(wpath, &sb) == 0) {
    if (! S_ISDIR(sb.st_mode)) {
      errno = ENOTDIR;
      c_free_locale_string(wpath);
      return -1;
    }
  }

  tmp = strlen(path);
  while(tmp > 0 && path[tmp - 1] == '/') --tmp;
  while(tmp > 0 && path[tmp - 1] != '/') --tmp;
  while(tmp > 0 && path[tmp - 1] == '/') --tmp;

  if (tmp > 0) {
    char subpath[tmp + 1];
    memcpy(subpath, path, tmp);
    subpath[tmp] = '\0';
    swpath = c_utf8_to_locale(subpath);
    if (_tstat(swpath, &sb) == 0) {
      if (! S_ISDIR(sb.st_mode)) {
	c_free_locale_string(swpath);
	c_free_locale_string(wpath);
        errno = ENOTDIR;
        return -1;
      }
    } else if (errno != ENOENT) {
      c_free_locale_string(wpath);
      c_free_locale_string(swpath);
      return -1;
    } else if (c_mkdirs(subpath, mode) < 0) {
      c_free_locale_string(swpath);
      c_free_locale_string(wpath);
      return -1;
    }
  }
  tmp = _tmkdir(wpath, mode);
  c_free_locale_string(swpath);
  c_free_locale_string(wpath);

  if ((tmp < 0) && (errno == EEXIST)) {
    return 0;
  }
  return tmp;
}
コード例 #14
0
ファイル: MakeDir.cpp プロジェクト: agran147/FieldWorks
DEFINE_THIS_FILE

/*----------------------------------------------------------------------------------------------
	This is called recursively to create all the directories in the given path. If any part of
	the path already exists, then that is not a problem.

	@param pszPath Path whose directories are to be created.
	@return False if path did not exist and could not be created, otherwise True.
----------------------------------------------------------------------------------------------*/
bool MakeDir(const achar * pszPath)
{
#if WIN32
	StrAppBufPath strbp(pszPath);

	// Look for last backslash:
	StrAppBuf strbSlash("\\");
#else
	StrAnsiBufPath strbp(pszPath);

	// Look for last slash:
	StrAnsiBuf strbSlash("/");
#endif
	int ichStart = strbp.ReverseFindCh(strbSlash[0]);
	if (ichStart > 0)
	{
		// Make path comprising all except last component:
		StrAppBufPath strbpSmaller;
		strbpSmaller.Assign(strbp.Left(ichStart).Chars());

		// Check for recursion base case - no more backslashes:
		ichStart = strbpSmaller.ReverseFindCh(strbSlash[0]);
		if (ichStart > 0)
		{
			if (!MakeDir(strbpSmaller))
				return false;
		}
	}
	// If this next call fails, it may only be because the path already exists, so we will check
	// our overall success afterwards:
#if WIN32
	_tmkdir(strbp.Chars());
	DWORD nFlags = GetFileAttributes(strbp.Chars());
	if (nFlags == INVALID_FILE_ATTRIBUTES || !(nFlags & FILE_ATTRIBUTE_DIRECTORY))
		return false;
#else
	mkdir(strbp.Chars(), 0777);

	struct stat filestats;
	bool statfailed = stat(strbp.Chars(), &filestats);
	if (!statfailed && !S_ISDIR(filestats.st_mode))
		return false;
#endif
	return true;
}
コード例 #15
0
ファイル: qtmain.cpp プロジェクト: ldraw-linux/leocad
static void lcSehInit()
{
	if (SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, minidumpPath) == S_OK)
	{
		lstrcat(minidumpPath, TEXT("\\LeoCAD\\"));
		_tmkdir(minidumpPath);
		lstrcat(minidumpPath, TEXT("minidump.dmp"));
	}

	SetUnhandledExceptionFilter(lcSehHandler);
}
コード例 #16
0
ファイル: posix_emu.cpp プロジェクト: DavidLudwig/macemu
int my_mkdir( const char *path, int mode )
{
	DISABLE_ERRORS;
	auto tpath = tstr(path);
	LPTSTR p = MRP(tpath.get());
	strip_trailing_bs(p);
	int result = _tmkdir( p );
	if(result < 0) {
		make_folders(p);
		result = _tmkdir( p );
	}
	if(result < 0) {
		my_errno = errno;
	} else {
		my_errno = 0;
	}
	D(bug(TEXT("mkdir(%s,%s,%d) = %d\n"), tpath.get(), p, mode, result));
	RESTORE_ERRORS;
	return result;
}
コード例 #17
0
ファイル: DatabaseArray.cpp プロジェクト: moodboom/Reusable
//-------------------------------------------------------------------//
// GetDBBackupPath()																	//
//-------------------------------------------------------------------//
void DatabaseArray::GetDBBackupPath( 
	CString* pstrPath
) {

	GetDatabasePath( pstrPath );
	*pstrPath += _T("Backup\\");

	// Make sure it exists.
	_tmkdir( LPCTSTR( *pstrPath ) );


}
コード例 #18
0
ファイル: posix_emu.cpp プロジェクト: DavidLudwig/macemu
static void make_folders( LPCTSTR path )
{
	TCHAR local_path[_MAX_PATH], *p;
	_tcscpy( local_path, path );
	p = _tcsrchr( local_path, TEXT('\\') );
	if(p) {
		*p = 0;
		if(_tcslen(local_path) > 3) {
			make_folders(local_path);
			_tmkdir(local_path);
		}
	}
}
コード例 #19
0
ファイル: check_vio_ext.c プロジェクト: Hopebaytech/client
// https://github.com/owncloud/client/issues/3128 https://github.com/owncloud/client/issues/2777
static void check_readdir_bigunicode(void **state)
{
    statevar *sv = (statevar*) *state;
//    1: ? ASCII: 239 - EF
//    2: ? ASCII: 187 - BB
//    3: ? ASCII: 191 - BF
//    4: ASCII: 32    - 20

    char *p = 0;
    asprintf( &p, "%s/%s", CSYNC_TEST_DIR, "goodone/" );
    int rc = _tmkdir(p, MKDIR_MASK);
    assert_int_equal(rc, 0);
    SAFE_FREE(p);

    const char *t1 = "goodone/ugly\xEF\xBB\xBF\x32" ".txt";
    asprintf( &p, "%s/%s", CSYNC_TEST_DIR, t1 );
    rc = _tmkdir(p, MKDIR_MASK);
    SAFE_FREE(p);

    assert_int_equal(rc, 0);

    int files_cnt = 0;
    traverse_dir(state, CSYNC_TEST_DIR, &files_cnt);
    const char *expected_result =  "<DIR> C:/tmp/csync_test/goodone"
#ifndef __APPLE__
        // On Mac, iconv will not return some files with fancy unicode.
        // Linux is not so picky about it and return everything and let the sync engine deal with it.
                                   "<DIR> C:/tmp/csync_test/goodone/ugly\xEF\xBB\xBF\x32" ".txt"
#endif
                                   ;
    assert_string_equal( sv->result, expected_result);

#ifdef __APPLE__
    // Bad one is recognized though.. !
    assert_string_equal( sv->ignored_dir, CSYNC_TEST_DIR "/goodone/" "ugly\xEF\xBB\xBF\x32" ".txt");
#endif
    assert_int_equal(files_cnt, 0);
}
コード例 #20
0
ファイル: FileUtils.cpp プロジェクト: CSanchezAustin/cslib
bool 
FileUtils::mkdir( 
    const String &dirName )
{
    ASSERT_D( dirName.length() > 0 );
    int res = 0;

#if defined(_WINDOWS) || defined(WIN32)
    res = _tmkdir( dirName.c_str() );
#else    
    res = ::mkdir(dirName.c_str(), 0755);
#endif

    return (res == 0) || (res == -1 && errno == EEXIST);
}
コード例 #21
0
ファイル: check_vio.c プロジェクト: JamesFmoran/client
static void setup_dir(void **state) {
    int rc;
    mbchar_t *dir = c_utf8_path_to_locale(CSYNC_TEST_DIR);

    setup(state);

    rc = _tmkdir(dir, MKDIR_MASK);
    c_free_locale_string(dir);
    assert_int_equal(rc, 0);

    assert_non_null(getcwd(wd_buffer, WD_BUFFER_SIZE));

    rc = chdir(CSYNC_TEST_DIR);
    assert_int_equal(rc, 0);
}
コード例 #22
0
ファイル: stringlist.cpp プロジェクト: yinweli/platform
//-----------------------------------------------------------------------------
// 存檔
bool C_StringList::Save(IN const nstring &szFilePath, IN bool bAppend, IN bool bAutoWrap, IN unsigned long ulPos, IN unsigned long ulLines)
{
	if(szFilePath.empty())
		return C_NOutput::Instance().Error(ERRORNSTD, __T("file empty"));

	if(ulPos >= m_StringList.size())
		return C_NOutput::Instance().Error(ERRORNSTD, __T("pos error(") + szFilePath + __T(")"));

	std::vector<nstring> DirList;
	std::list<nstring>::iterator ItorS = GetItor(m_StringList, ulPos); // 開始位置
	std::list<nstring>::iterator ItorE = GetItor(m_StringList, ulPos + ulLines); // 結束位置
	std::list<nstring>::iterator Itor = ItorS;
	std::string szTemp;

	// 取得目錄列表
	FindPathDir(szFilePath, DirList, true);

	// 建立目錄
	for(unsigned long ulCount = 0, iMax = DirList.size() - 1; ulCount < iMax; ++ulCount)
		_tmkdir(DirList[ulCount].c_str());

	// 開啟檔案
	FILE *f = NULL;

	if(_tfopen_s(&f, szFilePath.c_str(), bAppend ? __T("a+b") : __T("w+b")) != 0)
		return C_NOutput::Instance().Error(ERRORNSTD, __T("open file failed(") + szFilePath + __T(")"));

	if(f == NULL)
		return C_NOutput::Instance().Error(ERRORNSTD, __T("open file failed(") + szFilePath + __T(")"));

	while(Itor != ItorE)
	{
		// 取得要存檔的字串
		szTemp = C_NString(*Itor).c_str();
		// 添加換行字元
		szTemp += bAutoWrap ? "\n" : "";
		// 存檔
		fwrite(szTemp.c_str(), szTemp.size(), 1, f);

		++Itor;
	}//while

	// 關檔
	fclose(f);

	return true;
}
コード例 #23
0
ファイル: TestUtils.cpp プロジェクト: killbug2004/WSProf
void CTestUtils::RecursiveCreateDirectoryIfNecessary(CStdString sTempPath)
{
	int iBackSlashPos = sTempPath.ReverseFind('\\');

	if (iBackSlashPos == -1)
	{
		return;
	}

	CStdString sPath = sTempPath.Mid(0, iBackSlashPos);

	if (_taccess(sPath, 0) == -1)
	{
		RecursiveCreateDirectoryIfNecessary(sPath);
		_tmkdir(sPath);
	}
}
コード例 #24
0
int LogFile(CString LogItem, CString LogEnrty, CString LogMessage)
{	
	SYSTEMTIME st;   
	CString LogTime;
	CString LogFileFullName;

	GetSystemTime(&st);  
	LogTime.Format(_T("%4d\\%2d\\%2d %2d:%2d:%2d::%3d"), st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute, st.wSecond, st.wMilliseconds);
	LogEnrty = _T("(") + LogTime + _T(")   ") + LogEnrty; //     (YYY/MM/DD HH:MM:SS::MS)  LogEntry = LogMessage 
	
	TCHAR	dirPath[255];
	//SHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL, 0, dirPath);
	_stprintf(dirPath, _T("%s"), _T("C:\\OEM\\Cloud"));
	_tmkdir(dirPath);
	LogFileFullName = CString("") + dirPath + _T("\\CloudMediaAgent_Log.txt");

	return WritePrivateProfileString((LPCTSTR)LogItem, (LPCTSTR)LogEnrty, (LPCTSTR)LogMessage, (LPCTSTR)LogFileFullName);

}
コード例 #25
0
ファイル: check_vio.c プロジェクト: JamesFmoran/client
static void check_csync_vio_opendir_perm(void **state)
{
    CSYNC *csync = *state;
    csync_vio_handle_t *dh;
    int rc;
    mbchar_t *dir = c_utf8_path_to_locale(CSYNC_TEST_DIR);

    assert_non_null(dir);

    rc = _tmkdir(dir, (S_IWUSR|S_IXUSR));
    assert_int_equal(rc, 0);

    dh = csync_vio_opendir(csync, CSYNC_TEST_DIR);
    assert_null(dh);
    assert_int_equal(errno, EACCES);

    _tchmod(dir, MKDIR_MASK);
    c_free_locale_string(dir);
}
コード例 #26
0
ファイル: check_vio.c プロジェクト: Gnostech/mirall
static void check_csync_vio_mkdirs_some_exist(void **state)
{
    CSYNC *csync = *state;
    csync_stat_t sb;
    mbchar_t *this_dir = c_utf8_to_locale("/tmp/csync_test/this");
    mbchar_t *stat_dir = c_utf8_to_locale(CSYNC_TEST_DIRS);
    int rc;

    rc = _tmkdir(this_dir, MKDIR_MASK);
    assert_int_equal(rc, 0);
    rc = csync_vio_mkdirs(csync, CSYNC_TEST_DIRS, MKDIR_MASK);
    assert_int_equal(rc, 0);

    rc = _tstat(stat_dir, &sb);
    assert_int_equal(rc, 0);

    _trmdir(stat_dir);
    c_free_locale_string(this_dir);
    c_free_locale_string(stat_dir);
}
コード例 #27
0
ファイル: mkdir.c プロジェクト: BoxianLai/moxiedev
int
__gnat_mkdir (char *dir_name, int encoding ATTRIBUTE_UNUSED)
{
#if defined (__vxworks) && !(defined (__RTP__) && (_WRS_VXWORKS_MINOR != 0))
  return mkdir (dir_name);
#elif defined (__MINGW32__)
  TCHAR wname [GNAT_MAX_PATH_LEN + 2];

  if (encoding == Encoding_Unspecified)
    S2WSC (wname, dir_name, GNAT_MAX_PATH_LEN);
  else if (encoding == Encoding_UTF8)
    S2WSU (wname, dir_name, GNAT_MAX_PATH_LEN);
  else
    S2WS (wname, dir_name, GNAT_MAX_PATH_LEN);

  return _tmkdir (wname);
#else
  return mkdir (dir_name, S_IRWXU | S_IRWXG | S_IRWXO);
#endif
}
コード例 #28
0
ファイル: filesys.c プロジェクト: ctubio/alpine
int
our_mkdir(char *path, mode_t mode)
{
#ifdef _WINDOWS
    /* mode is a noop for _WINDOWS */
    LPTSTR p = NULL;
    int ret = -1;

    p = utf8_to_lptstr((LPSTR) path);

    if(p){
	ret = _tmkdir(p);
	fs_give((void **) &p);
    }

    return ret;
#else /* UNIX */
    return(mkdir(fname_to_locale(path), mode));
#endif /* UNIX */
}
コード例 #29
0
bool CToolBox::MakeDirectory(const TCHAR *dirpath)
{
#ifdef WIN32
	if (!_tmkdir(dirpath))
		return true;
	else
	{
		int error = errno;
		if (error == EEXIST)
		{
			Log(LOGWARNING, _T("MakeDirectory: Cannot create new directory at %s, already exists.\n"));
			return true;
		}
		if (error == ENOENT)
            Log(LOGWARNING, _T("MakeDirectory: Cannot create new directory at %s, path does not exist.\n"));
		return false;
	}
#else
	return false;
#endif
}
コード例 #30
0
ファイル: weather_ini.cpp プロジェクト: ybznek/miranda-ng
//============  WEATHER INI SETUP DIALOG  ============
//
static INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);

		// make the buttons flat
		SendDlgItemMessage(hwndDlg, IDC_STEP1, BUTTONSETASFLATBTN, TRUE, 0);
		SendDlgItemMessage(hwndDlg, IDC_STEP2, BUTTONSETASFLATBTN, TRUE, 0);
		SendDlgItemMessage(hwndDlg, IDC_STEP3, BUTTONSETASFLATBTN, TRUE, 0);
		SendDlgItemMessage(hwndDlg, IDC_STEP4, BUTTONSETASFLATBTN, TRUE, 0);

		// set icons
		Window_SetIcon_IcoLib(hwndDlg, GetIconHandle("main"));

		WindowList_Add(hWindowList, hwndDlg, NULL);
		ShowWindow(hwndDlg, SW_SHOW);
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_STEP1:
			// update current data
			Utils_OpenUrl("http://miranda-ng.org/");
			break;

		case IDC_STEP2:
		{
			TCHAR szPath[1024];
			GetModuleFileName(GetModuleHandle(NULL), szPath, _countof(szPath));
			TCHAR *chop = _tcsrchr(szPath, '\\');
			if (chop) {
				*chop = '\0';
				mir_tstrncat(szPath, _T("\\Plugins\\weather\\"), _countof(szPath) - mir_tstrlen(szPath));
				if (_tmkdir(szPath) == 0)
					ShellExecute((HWND)lParam, _T("open"), szPath, _T(""), _T(""), SW_SHOW);
			}
			break;
		}

		case IDC_STEP3:
			if (LoadWIData(false))
				MessageBox(NULL,
					TranslateT("All update data has been reloaded."),
					TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
			break;

		case IDC_STEP4:
			WeatherAdd(0, 0);
			// fall through
		case IDCANCEL:
			// close the info window
			DestroyWindow(hwndDlg);
			break;
		}
		break;

	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		break;

	case WM_DESTROY:
		Window_FreeIcon_IcoLib(hwndDlg);
		break;
	}
	return FALSE;
}