示例#1
0
文件: posix_w32.c 项目: aep/libgit2
int p_unlink(const char *path)
{
	git_win32_path buf;
	git_win32_path_from_c(buf, path);
	_wchmod(buf, 0666);
	return _wunlink(buf);
}
示例#2
0
int p_unlink(const char *path)
{
	wchar_t buf[GIT_WIN_PATH];
	git__utf8_to_16(buf, GIT_WIN_PATH, path);
	_wchmod(buf, 0666);
	return _wunlink(buf);
}
示例#3
0
/*
 *  cleanup
 *
 *  Removes output files that are not fully and properly created.
 */
void cleanup(const wchar_t *outfile)
{
    if (wcscmp(outfile,L"-") && outfile[0] != '\0')
    {
        _wunlink(outfile);
    }
}
示例#4
0
/**
 * g_unlink:
 * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
 *
 * A wrapper for the POSIX unlink() function. The unlink() function
 * deletes a name from the filesystem. If this was the last link to the
 * file and no processes have it opened, the diskspace occupied by the
 * file is freed.
 *
 * See your C library manual for more details about unlink(). Note
 * that on Windows, it is in general not possible to delete files that
 * are open to some process, or mapped into memory.
 *
 * Returns: 0 if the name was successfully deleted, -1 if an error
 *    occurred
 *
 * Since: 2.6
 */
int
g_unlink (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 = _wunlink (wfilename);
    save_errno = errno;

    g_free (wfilename);

    errno = save_errno;
    return retval;
#else
    return unlink (filename);
#endif
}
bool delete_file(const std::string &src) {
#ifdef _WIN32
  return 0 == _wunlink(Unicode(src).path());
#else
  return 0 == unlink(Unicode(src).path());
#endif
}
示例#6
0
static void kill_fsdb (a_inode *dir)
{
	if (!dir->nname)
		return;
  TCHAR *n = build_nname (dir->nname, FSDB_FILE);
  _wunlink (n);
  xfree (n);
}
示例#7
0
static int rt_unlink(EIF_FILENAME path)
{
#ifdef EIF_WINDOWS
	return _wunlink(path);
#else
	return unlink(path);
#endif
}
示例#8
0
int S_windows_unlink(const char *pathname) {
  wchar_t wpathname[PATH_MAX];
  if (MultiByteToWideChar(CP_UTF8,0,pathname,-1,wpathname,PATH_MAX) == 0)
    return _unlink(pathname);
  else {
    int rc;
    if (!(rc = _wunlink(wpathname))) {
      // Spin loop until Windows deletes the file.
      int n;
      for (n = 100; n > 0; n--) {
        if (_wunlink(wpathname) && (errno == ENOENT)) break;
      }
      return 0;
    }
    return rc;
  }
}
示例#9
0
文件: wfile.c 项目: Skiles/aseprite
/* _al_win_unlink:
 *  Remove a file with unlink() or _wunlink() depending on whether Unicode
 *  filenames are supported by this version of Windows and compiler.
 */
int _al_win_unlink(const char *pathname)
{
   if (get_filename_encoding() != U_UNICODE) {
      return unlink(pathname);
   }
   else {
      return _wunlink((wchar_t*)pathname);
   }
}
示例#10
0
/* _al_win_unlink:
 *  Remove a file with unlink() or _wunlink() depending on whether Unicode
 *  filenames are supported by this version of Windows and compiler.
 */
int _al_win_unlink(const char *pathname)
{
   if (!_al_win_unicode_filenames) {
      return unlink(pathname);
   }
   else {
      return _wunlink((wchar_t*)pathname);
   }
}
示例#11
0
int unlink_utf8(const char *filename)
{
	wchar_t *wname;
	int ret;

	if (!(wname = wchar_from_utf8(filename))) return -1;
	ret = _wunlink(wname);
	free(wname);

	return ret;
}
示例#12
0
文件: os_windows.c 项目: peluse/nvml
/*
 * os_unlink -- unlink abstraction layer
 */
int
os_unlink(const char *pathname)
{
	wchar_t *path = util_toUTF16(pathname);
	if (path == NULL)
		return -1;

	int ret = _wunlink(path);
	util_free_UTF16(path);
	return ret;
}
示例#13
0
bool plFileSystem::Unlink(const plFileName &filename)
{
#if HS_BUILD_FOR_WIN32
    plStringBuffer<wchar_t> wfilename = filename.AsString().ToWchar();
    _wchmod(wfilename, S_IWRITE);
    return _wunlink(wfilename) == 0;
#else
    chmod(filename.AsString().c_str(), S_IWRITE);
    return unlink(filename.AsString().c_str()) == 0;
#endif
}
示例#14
0
文件: osdep.c 项目: 0x0B501E7E/x264
int x264_rename( const char *oldname, const char *newname )
{
    wchar_t oldname_utf16[MAX_PATH];
    wchar_t newname_utf16[MAX_PATH];
    if( utf8_to_utf16( oldname, oldname_utf16 ) && utf8_to_utf16( newname, newname_utf16 ) )
    {
        /* POSIX says that rename() removes the destination, but Win32 doesn't. */
        _wunlink( newname_utf16 );
        return _wrename( oldname_utf16, newname_utf16 );
    }
    return -1;
}
示例#15
0
文件: posix_w32.c 项目: gitpan/Git-XS
int p_unlink(const char *path)
{
	int ret = 0;
	wchar_t* buf;

	buf = gitwin_to_utf16(path);
	_wchmod(buf, 0666);
	ret = _wunlink(buf);
	git__free(buf);

	return ret;
}
示例#16
0
    void Trainer::Save(const std::wstring& modelFilePath, const std::vector<DictionaryValue>& learnerState, const Dictionary& externalState, const Dictionary& distributedState)
    {
        std::wstring tempModelFile = modelFilePath + L".tmp";
        Dictionary state;
        state[versionPropertyName] = trainerCheckpointVersion;
        state[learnersPropertyName] = learnerState;
        state[externalStatePropertyName] = externalState;
        state[distributedStatePropertyName] = distributedState;

        m_combinedTrainingFunction->Save(tempModelFile);
        std::wstring trainerStateCheckpointFilePath = GetTrainerStateCheckpointFilePath(modelFilePath);
        std::wstring tempCheckpointFile = trainerStateCheckpointFilePath + L".tmp";

        state.Save(tempCheckpointFile);

        // The return value is ignored here.
        _wunlink(modelFilePath.c_str());
        _wunlink(trainerStateCheckpointFilePath.c_str());

        renameOrDie(tempModelFile, modelFilePath);
        renameOrDie(tempCheckpointFile, trainerStateCheckpointFilePath);
    }
int ADM_unlink(const char *filename)
{
#ifdef __WIN32
	int filenameLength = utf8StringToWideChar(filename, -1, NULL);
	wchar_t wcFilename[filenameLength];

	utf8StringToWideChar(filename, -1, wcFilename);

	return _wunlink(wcFilename);
#else
	return unlink(filename);
#endif
}
示例#18
0
bool plFileUtils::RemoveFile(const wchar_t* filename, bool delReadOnly)
{
#ifdef HS_BUILD_FOR_WIN32
    if (delReadOnly)
        _wchmod(filename, S_IWRITE);
    return (_wunlink(filename) == 0);
#elif HS_BUILD_FOR_UNIX
    const char* cfilename = hsWStringToString(filename);
    bool ret = RemoveFile(cfilename, delReadOnly);
    delete[] cfilename; /* Free the string */

    return ret;
#endif
}
示例#19
0
/*! \brief Create an empty file
	\param filename The desired (path+)name of the file
	\returns XRV_OK if the file was created successfully
*/
XsResultValue IoInterfaceFile::create(const XsString& filename)
{
	if (m_handle) return m_lastResult = XRV_ALREADYOPEN;

//! \test does this work for non-existing files? Or do we need a check and
//! create?
#ifdef _WIN32
	m_handle = _wfopen(
		filename.toStdWString().c_str(), L"w+b");  // open for update (r/w)
#else
	m_handle = fopen(filename.c_str(), "w+b");  // open for update (r/w)
#endif
	if (m_handle == nullptr) return m_lastResult = XRV_OUTPUTCANNOTBEOPENED;

	bool fail = false;
#ifdef _WIN32
	wchar_t fullpath[XS_MAX_FILENAME_LENGTH];
	if (_wfullpath(
			fullpath, filename.toStdWString().c_str(),
			XS_MAX_FILENAME_LENGTH) == nullptr)
		fail = true;
#else
	// based on the assumption that this doesn't concern the serial port, handle
	// it the same way using realpath(). Apparently realpath() doesn't require a
	// maximum length. One would possibly want to write a wrapper for it.
	char fullpath[XS_MAX_FILENAME_LENGTH * 2];
	if (realpath(filename.c_str(), fullpath) == nullptr) fail = true;
#endif
	m_filename = XsString(fullpath);

	if (fail)
	{
		fclose(m_handle);
#ifdef _WIN32
		_wunlink(m_filename.toStdWString().c_str());
#else
		unlink(m_filename.c_str());
#endif
		m_handle = 0;
		return m_lastResult = XRV_INVALIDPARAM;
	}

	m_readPos = 0;
	m_writePos = 0;
	m_fileSize = 0;
	m_reading = true;
	m_readOnly = false;
	return m_lastResult = XRV_OK;
}
示例#20
0
int flac_internal_unlink_utf8(const char *filename)
{
	if (!utf8_filenames) {
		return _unlink(filename);
	} else {
		wchar_t *wname;
		int ret;

		if (!(wname = wchar_from_utf8(filename))) return -1;
		ret = _wunlink(wname);
		free(wname);

		return ret;
	}
}
示例#21
0
bool System_DeleteFile(char * fileName)
{
   bool result = true;
#if defined(__WIN32__)
   uint16 * _wfileName = __ecereNameSpace__ecere__sys__UTF8toUTF16(fileName, null);
   if(_wunlink(_wfileName))
      result = false;
      //if(errno == 13/*EACCES*/) printf("delete file access error\n");
      //else if(errno == 2/*ENOENT*/) printf("delete file file does not exist error\n");
   __ecereNameSpace__ecere__com__eSystem_Delete(_wfileName);
#else
   unlink(fileName);
#endif
   return result;
}
示例#22
0
	bool deleteFile(FileLocalization fileLocalization, const char* filepath)
	{
#if defined(USES_WINDOWS8_DESKTOP) || defined(USES_WINDOWS_OPENGL)
		std::wstring fullfilepath = getFullPathUnicode(fileLocalization, filepath);
		return _wunlink(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 DeleteFileW(fullpath.c_str()) ? true : false;
#elif defined(USES_LINUX)
		std::wstring fullfilepath = getFullPathUnicode(fileLocalization, filepath);
		return unlink(Utils::convertWStringToString(fullfilepath).c_str()) == 0;
#else
#error
#endif
	}
示例#23
0
文件: tfile.c 项目: graphis/libk
static void trollback_one(struct tfile_t* tf, size_t off)
{
	close(tf->fd);
	#ifdef __WINNT__
	wchar_t* wtf = utf8_to_ucs2(tf->tmpfilename);
	if (wtf) {
		_wunlink(wtf);
		free(wtf);
	}
	#else
	unlink(tf->tmpfilename);
	#endif
	free(tf->filename);
	free(tf->tmpfilename);
	pool_cut(&mappool, off, sizeof(struct tfile_t));
}
示例#24
0
bool QFile::remove( const QString &fileName )
{
    if ( fileName.isEmpty() ) {
#if defined(CHECK_NULL)
	qWarning( "QFile::remove: Empty or null file name" );
#endif
	return FALSE;
    }
#if defined(__CYGWIN32_)
    // unlink more common in UNIX
    return ::remove( QFile::encodeName(fileName) ) == 0;	
#else
    QString str = fileName;
    reslashify(str);
    return ( _wunlink( (wchar_t*) str.ucs2() ) == 0 );
#endif
}
int File_RemoveW(
    _In_z_ const wchar_t* path)
{
#if defined(_MSC_VER)
    return _wunlink(path) == 0 ? 0 : -1;
#else
    char *filePath;
    int result;

    if( !UCS2ToAscii( path, &filePath) )
        return -1;

    result = unlink(filePath) == 0 ? 0 : -1;
    PAL_Free(filePath);
    return result;
#endif    
}
示例#26
0
int rename_utf8(const char *oldname_utf8, const char *newname_utf8)
{
	int ret = -1;
	
	wchar_t *oldname_utf16 = utf8_to_utf16(oldname_utf8);
	wchar_t *newname_utf16 = utf8_to_utf16(newname_utf8);
	
	if(oldname_utf16 && newname_utf16)
	{
		_wunlink(newname_utf16);
		ret = _wrename(oldname_utf16, newname_utf16);
	}

	if(newname_utf16) free(newname_utf16);
	if(oldname_utf16) free(oldname_utf16);

	return ret;
}
示例#27
0
void ConvertUtil::CreateSQLiteFile(FdoIConnection *connection, FdoString *file)
{
    _wunlink(file);

    int    count = 0;
    wchar_t buffer[512];
    FdoString **names = NULL;
    
    swprintf(buffer, 512, L"File=%ls;UseFdoMetadata=TRUE", file);
    connection->SetConnectionString(buffer);

    FdoPtr<FdoICreateDataStore>    dataStore = static_cast<FdoICreateDataStore*>(connection->CreateCommand(FdoCommandType_CreateDataStore));
    FdoPtr<FdoIDataStorePropertyDictionary> dictionary = dataStore->GetDataStoreProperties();

    names = dictionary->GetPropertyNames(count);
    dictionary->SetProperty(names[0], file);

    dataStore->Execute();
}
示例#28
0
/**
 * The unlink function deletes the file named filename from the persistent storage.
 */
int pcsl_file_unlink(const pcsl_string * fileName)
{
    int status;
    const jchar * pszOsFilename = pcsl_string_get_utf16_data(fileName);

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

    if (_wunlink(pszOsFilename) < 0) {
    	status = -1;
    } else {
    	status = 0;
    }

    pcsl_string_release_utf16_data(pszOsFilename, fileName);

    return status;
}
示例#29
0
void FileAccessWindows::close() {

	if (!f)
		return;

	fclose(f);
	f = NULL;

	if (save_path!="") {

		//unlink(save_path.utf8().get_data());
		//print_line("renaming..");
		_wunlink(save_path.c_str()); //unlink if exists
		int rename_error = _wrename((save_path+".tmp").c_str(),save_path.c_str());
		save_path="";
		ERR_FAIL_COND( rename_error != 0);
	}


}
示例#30
0
文件: unlink.c 项目: mirror/plibc
/**
 * @brief Delete a file
 *        If filename is a link, the link itself it removed.
 */
int _win_unlink(const char *filename)
{
  wchar_t szFile[_MAX_PATH + 1];
  long lRet;

  if (plibc_utf8_mode() == 1)
    lRet = plibc_conv_to_win_pathwconv_ex(filename, szFile, 0);
  else
    lRet = plibc_conv_to_win_path_ex(filename, (char *) szFile, 0);
  if (lRet != ERROR_SUCCESS)
  {
    SetErrnoFromWinError(lRet);
    return -1;
  }

  /* unlink sets errno */
  if (plibc_utf8_mode() == 1)
    return _wunlink(szFile);
  else
    return unlink((char *) szFile);
}