コード例 #1
0
ファイル: File_WIN32.cpp プロジェクト: trafficsim-jp/poco
void FileImpl::linkToImpl(const std::string& path, int type) const
{
	poco_assert (!_path.empty());

	if (type == 0)
	{
		if (CreateHardLinkA(path.c_str(), _path.c_str(), NULL) == 0)
			handleLastErrorImpl(_path);
	}
	else
	{
#if _WIN32_WINNT >= 0x0600 && defined(SYMBOLIC_LINK_FLAG_DIRECTORY)
		DWORD flags = 0;
		if (isDirectoryImpl()) flags |= SYMBOLIC_LINK_FLAG_DIRECTORY;
#ifdef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
		flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
#endif
		if (CreateSymbolicLinkA(path.c_str(), _path.c_str(), flags) == 0)
			handleLastErrorImpl(_path);
#else
		throw Poco::NotImplementedException("Symbolic link support not available in used version of the Windows SDK")
#endif

	}
}
コード例 #2
0
ファイル: fs.c プロジェクト: Cahya/node
void fs__link(uv_fs_t* req, const char* path, const char* new_path) {
  int result = CreateHardLinkA(new_path, path, NULL) ? 0 : -1;
  if (result == -1) {
    SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
  } else {
    SET_REQ_RESULT(req, result);
  }
}
コード例 #3
0
ファイル: CreateHardLinkA.cpp プロジェクト: IFGHou/Holodeck
BOOL My_CreateHardLinkA()
{
	LPCSTR lpFileName=NULL;
	LPCSTR lpExistingFileName=NULL;
	LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL;
	BOOL returnVal_Real = NULL;
	BOOL returnVal_Intercepted = NULL;

	DWORD error_Real = 0;
	DWORD error_Intercepted = 0;
	disableInterception();
	returnVal_Real = CreateHardLinkA (lpFileName,lpExistingFileName,lpSecurityAttributes);
	error_Real = GetLastError();
	enableInterception();
	returnVal_Intercepted = CreateHardLinkA (lpFileName,lpExistingFileName,lpSecurityAttributes);
	error_Intercepted = GetLastError();
	return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted));
}
コード例 #4
0
ファイル: System.cpp プロジェクト: Shikifuyin/Scarab-Engine
Bool System::CreateHardLink( const GChar * strPathName, const GChar * strTargetPathName ) const
{
#if ( defined(UNICODE) || defined (_UNICODE) )
    BOOL bRes = CreateHardLinkW( strPathName, strTargetPathName, NULL );
#else
    BOOL bRes = CreateHardLinkA( strPathName, strTargetPathName, NULL );
#endif
    return ( bRes != FALSE );
}
コード例 #5
0
static int
win32_pghardlink(const char *src, const char *dst)
{
	/*
	 * CreateHardLinkA returns zero for failure
	 * http://msdn.microsoft.com/en-us/library/aa363860(VS.85).aspx
	 */
	if (CreateHardLinkA(dst, src, NULL) == 0)
		return -1;
	else
		return 0;
}
コード例 #6
0
ファイル: util.c プロジェクト: FeepingCreature/swig
int safe_rename(const char* oldpath, const char* newpath)
{
	/* safe_rename is for creating entries in the cache.

	   Works like rename(), but it never overwrites an existing
	   cache entry. This avoids corruption on NFS. */
#ifndef _WIN32
	int status = link(oldpath, newpath);
	if( status == 0 || errno == EEXIST )
#else
	int status = CreateHardLinkA(newpath, oldpath, NULL) ? 0 : -1;
	if( status == 0 || GetLastError() == ERROR_ALREADY_EXISTS )
#endif
	{
		return unlink( oldpath );
	}
	else
	{
		return -1;
	}
}