Example #1
0
/*----------------------------------------------------------------------*
                             rtp_wfile_rmdir
 *----------------------------------------------------------------------*/
int rtp_wfile_rmdir (unsigned short * name)
{
#if (_WIN32_WINNT) >= 0x0400

#ifdef RTP_DEBUG
    int result;
    /* ----------------------------------- */
    /*  Clear the error state by setting   */
    /*  to 0.                              */
    /* ----------------------------------- */
    SetLastError (0);
#endif

    name = _rtp_unicode_name_to_winname (name);

    if (_wrmdir ((const unsigned short *)name) != 0)
    {
#ifdef RTP_DEBUG
        result = GetLastError();
        RTP_DEBUG_OUTPUT_STR("rtp_wfile_rmdir: error returned ");
        RTP_DEBUG_OUTPUT_INT(result);
        RTP_DEBUG_OUTPUT_STR(".\n");
#endif
        return (-1);
    }
    return (0);
#endif
	return (-1);
}
Example #2
0
/**
 * g_rmdir:
 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
 *
 * A wrapper for the POSIX rmdir() function. The rmdir() function
 * deletes a directory from the filesystem.
 *
 * See your C library manual for more details about how rmdir() works
 * on your system.
 *
 * Returns: 0 if the directory was successfully removed, -1 if an error
 *    occurred
 *
 * Since: 2.6
 */
int
g_rmdir (const gchar *filename)
{
#ifdef G_OS_WIN32
    wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
    int retval;
    int save_errno;

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

    retval = _wrmdir (wfilename);
    save_errno = errno;

    g_free (wfilename);

    errno = save_errno;
    return retval;
#else
    return rmdir (filename);
#endif
}
Example #3
0
GF_Err gf_rmdir(const char *DirPathName)
{
#if defined (_WIN32_WCE)
	TCHAR swzName[MAX_PATH];
	BOOL res;
	CE_CharToWide(DirPathName, swzName);
	res = RemoveDirectory(swzName);
	if (! res) {
		int err = GetLastError();
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot delete directory %s: last error %d\n", DirPathName, err ));
	}
#elif defined (WIN32)
	int res;
	wchar_t* wcsDirPathName = utf8_to_wcs(DirPathName);
	if (!wcsDirPathName)
		return GF_IO_ERR;
	res = _wrmdir(wcsDirPathName);
	gf_free(wcsDirPathName);
	if (res == -1) {
		int err = GetLastError();
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot delete directory %s: last error %d\n", DirPathName, err ));
		return GF_IO_ERR;
	}
#else
	int res = rmdir(DirPathName);
	if (res==-1) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("Cannot delete directory %s: last error %d\n", DirPathName, errno  ));
		return GF_IO_ERR;
	}
#endif
	return GF_OK;
}
Example #4
0
int S_windows_rmdir(const char *pathname) {
  wchar_t wpathname[PATH_MAX];
  if (MultiByteToWideChar(CP_UTF8,0,pathname,-1,wpathname,PATH_MAX) == 0)
    return _rmdir(pathname);
  else {
    int rc;
    if (!(rc = _wrmdir(wpathname))) {
      // Spin loop until Windows deletes the directory.
      int n;
      for (n = 100; n > 0; n--) {
        if (_wrmdir(wpathname) && (errno == ENOENT)) break;
      }
      return 0;
    }
    return rc;
  }
}
Example #5
0
int SharedUtil::File::Rmdir(const char* szPath)
{
#ifdef WIN32
    return _wrmdir(FromUTF8(szPath));
#else
    return rmdir(szPath);
#endif
}
Example #6
0
bool FileSystem::RemoveDirectory(const char* dirFilename)
{
#ifdef WIN32
	return _wrmdir(UtfPathToWidePath(dirFilename)) == 0;
#else
	return rmdir(dirFilename) == 0;
#endif
}
Example #7
0
 inline bool directory::remove(const string &pathname) {
   lstring list = directory::contents(pathname);
   for(auto &name : list) {
     if(name.endswith("/")) directory::remove({pathname, name});
     else file::remove({pathname, name});
   }
   return _wrmdir(utf16_t(pathname)) == 0;
 }
Example #8
0
int p_rmdir(const char* path)
{
	wchar_t* buf = gitwin_to_utf16(path);
	int ret = _wrmdir(buf);

	git__free(buf);
	return ret;
}
Example #9
0
static int rt_rmdir(EIF_FILENAME path)
{
#ifdef EIF_WINDOWS
	return _wrmdir(path);
#else
	return rmdir(path);
#endif
}
Example #10
0
bool System_RemoveDir(char * path)
{
   bool result = false;
   char location[MAX_LOCATION] = "";
   int locationLen = 0;
   int c = 0;
#ifdef __WIN32__
   if(path[0] && path[1] == ':')
      c = 2;
   else if(path[0] == '\\' && path[1] == '\\')
      c = 2;
   else
#endif
   if(path[0] == '/' || path[0] == '\\')
      c = 1;

   strncpy(location, path, c);
   location[c] = '\0';
   locationLen = c;

   for(; path[c]; )
   {
      char directory[MAX_FILENAME];
      int len = 0;
      char ch;
      for(;(ch = path[c]) && (ch == '/' || ch == '\\'); c++);
      for(;(ch = path[c]) && (ch != '/' && ch != '\\'); c++)
      {
         if(len < MAX_FILENAME)
            directory[len++] = ch;  
      }
      directory[len] = '\0';
      if(locationLen > 0 &&
         (location[locationLen-1] != '\\' && location[locationLen-1] != '/'))
         strcat(location, DIR_SEPS);
      strcat(location, directory);
      locationLen = strlen(location);

      if(FILE_FileExists(location) == isDirectory)
      {
#if defined(__unix__) || defined(__APPLE__)
         rmdir(location);
#else
         uint16 _wlocation[MAX_LOCATION];
         __ecereNameSpace__ecere__sys__UTF8toUTF16Buffer(location, _wlocation, MAX_LOCATION);
         _wrmdir(_wlocation);
#endif
         result = true;
      }
   }
   return result;
}
Example #11
0
/**
 * The function deletes the directory named dirName from the persistent storage.
 */
int pcsl_file_rmdir(const pcsl_string * dirName)
{
    int res;
    const jchar * pszOsFilename = pcsl_string_get_utf16_data(dirName);

    if (NULL == pszOsFilename) {
        return -1;
    }

    res = _wrmdir(pszOsFilename);
    pcsl_string_release_utf16_data(pszOsFilename, dirName);

    return (0 == res) ? 0 : -1;
}
Example #12
0
	bool rmdir(FileLocalization fileLocalization, const char* filepath)
	{
#if defined(USES_WINDOWS8_DESKTOP) || defined(USES_WINDOWS_OPENGL)
		std::wstring fullfilepath = getFullPathUnicode(fileLocalization, filepath);
		return _wrmdir(fullfilepath.c_str()) == 0;
#elif defined(USES_WINDOWS8_METRO)
		Windows::Storage::StorageFolder^ folder = getStorageFolder(fileLocalization);
		std::wstring fullpath = Utils::platformStringToWString(folder->Path) + L"\\" + Utils::convertStringToWString(filepath);
		return RemoveDirectoryW(fullpath.c_str()) ? true : false;
#elif defined(USES_LINUX)
		std::wstring fullfilepath = getFullPathUnicode(fileLocalization, filepath);
		return rmdir(Utils::convertWStringToString(fullfilepath).c_str()) == 0;
#else
#error
#endif
	}
Example #13
0
hpatch_BOOL hpatch_removeDir(const char* dirName_utf8){
    _path_noEndDirSeparator(dirName,dirName_utf8);{
#if (_IS_USED_WIN32_UTF8_WAPI)
        int     wsize;
        wchar_t path_w[hpatch_kPathMaxSize];
        wsize=_utf8FileName_to_w(dirName,path_w,hpatch_kPathMaxSize);
        if (wsize<=0) return hpatch_FALSE;
        return 0==_wrmdir(path_w);
#else
#   ifdef _MSC_VER
        return 0==_rmdir(dirName);
#   else
        return 0==rmdir(dirName);
#   endif
#endif
    }
}
Example #14
0
/**
	sys_remove_dir : string -> void
	<doc>Remove a directory. Exception on error</doc>
**/
static value sys_remove_dir( value path ) {
	#if defined(EPPC) || defined(KORE_CONSOLE)
	return alloc_bool(true);
	#else
	val_check(path,string);
	#ifdef NEKO_WINDOWS
	const wchar_t* _path = val_wstring(path);
	gc_enter_blocking();
	bool ok = _wrmdir(_path) != 0;
	#else
	const char* _path = val_string(path);
	gc_enter_blocking();
	bool ok = rmdir(_path) != 0;
	#endif
	gc_exit_blocking();
	return alloc_bool(ok);
	#endif
}
Example #15
0
/**
 * Deletes an empty directory from the persistent storage.
 *   If directory not empty this function must fail.
 * @param dirName path name in UNICODE of directory
 * @param dirNameLen length of directory name
 * @return <tt>JAVACALL_OK</tt> success
 *         <tt>JAVACALL_FAIL</tt> fail
 */
javacall_result javacall_fileconnection_delete_dir(const javacall_utf16* dirName,
                                                   int dirNameLen) {

    wchar_t wOsFilename[JAVACALL_MAX_FILE_NAME_LENGTH]; // max file name

    if( dirNameLen > JAVACALL_MAX_FILE_NAME_LENGTH ) {
        javacall_print("Error: javacall_fileconnection_delete_dir(), file name is too long\n");
        return JAVACALL_FAIL;
    }

    memcpy(wOsFilename, dirName, dirNameLen*sizeof(wchar_t));
    wOsFilename[dirNameLen] = 0;

    if(0 != _wrmdir(wOsFilename)) {
        javacall_print("Error: javacall_fileconnection_delete_dir(), cannot delete directory\n");
        return JAVACALL_FAIL;
    }
    return JAVACALL_OK;
}
int win_rmdir(const char *path)
{
    wchar_t *winpath;
    int ret;

    if (!strcmp("/", path)) {
	/* Emulate root */
	errno = EROFS;
	return -1;
    }

    winpath = intpath2winpath(path);
    if (!winpath) {
	errno = EINVAL;
	return -1;
    }

    ret = _wrmdir(winpath);
    free(winpath);
    return ret;
}
Example #17
0
/*----------------------------------------------------------------------*
                             rtp_wfile_rmdir
 *----------------------------------------------------------------------*/
int rtp_wfile_rmdir (unsigned short * name)
{
#if (_WIN32_WINNT) >= 0x0400

#ifdef RTP_DEBUG
    SetLastError (0);
#endif

    name = _rtp_unicode_name_to_winname (name);

    if (_wrmdir ((const unsigned short *)name) != 0)
    {
#ifdef RTP_DEBUG
		RTP_DEBUG_OUTPUT_ERRNO("rtp_wfile_rmdir:");
#endif
        return (-1);
    }
    return (0);
#endif
	return (-1);
}
Example #18
0
int VSIWin32FilesystemHandler::Rmdir( const char * pszPathname )

{
#if (defined(WIN32) && _MSC_VER >= 1310) || __MSVCRT_VERSION__ >= 0x0601
    if( CSLTestBoolean(
            CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) )
    {
        int nResult;
        wchar_t *pwszFilename = 
            CPLRecodeToWChar( pszPathname, CPL_ENC_UTF8, CPL_ENC_UCS2 );

        nResult = _wrmdir( pwszFilename );
        CPLFree( pwszFilename );
        return nResult;
    }
    else
#endif
    {
        return rmdir( pszPathname );
    }
}
void mmOperatingSystem::RemoveDir(mmString p_sDirName)
{
	int v_iRes = _wrmdir(p_sDirName.c_str());
	if(v_iRes != 0)
	{
		switch(errno)
		{
			case EACCES:
			{
				throw mmError(mmeFileIOPermissionToFileDenied);
			};
			case ENOENT:
			{
				throw mmError(mmeFileIONoSuchFileOrDirectory);
			};
			default:
			{
				throw mmError(mmeUnknownError);
			};
		};
	};
}
Example #20
0
/**
 * g_remove:
 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
 *
 * A wrapper for the POSIX remove() function. The remove() function
 * deletes a name from the filesystem.
 *
 * See your C library manual for more details about how remove() works
 * on your system. On Unix, remove() removes also directories, as it
 * calls unlink() for files and rmdir() for directories. On Windows,
 * although remove() in the C library only works for files, this
 * function tries first remove() and then if that fails rmdir(), and
 * thus works for both files and directories. Note however, that on
 * Windows, it is in general not possible to remove a file that is
 * open to some process, or mapped into memory.
 *
 * If this function fails on Windows you can't infer too much from the
 * errno value. rmdir() is tried regardless of what caused remove() to
 * fail. Any errno value set by remove() will be overwritten by that
 * set by rmdir().
 *
 * Returns: 0 if the file was successfully removed, -1 if an error
 *    occurred
 *
 * Since: 2.6
 */
int
ws_stdio_remove (const gchar *filename)
{
      wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
      int retval;
      int save_errno;

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

      retval = _wremove (wfilename);
      if (retval == -1)
	retval = _wrmdir (wfilename);
      save_errno = errno;

      g_free (wfilename);

      errno = save_errno;
      return retval;
}
Example #21
0
int rmdir_( BBString *path ){
	if( _bbusew ) return _wrmdir( bbTmpWString(path) );
	return _rmdir( bbTmpCString(path) );
}
 int __cdecl My_rmdir( const char *_Path )
 {
     return _wrmdir( FromUTF8( _Path ) );
 }
Example #23
0
axStatus	axFileSystem::_removeDir	( const wchar_t*    dir ) { 
	return _wrmdir( dir ); 
}