summaryrefslogtreecommitdiff
path: root/shared/symlink_target.h
diff options
context:
space:
mode:
Diffstat (limited to 'shared/symlink_target.h')
-rw-r--r--shared/symlink_target.h32
1 files changed, 15 insertions, 17 deletions
diff --git a/shared/symlink_target.h b/shared/symlink_target.h
index 200c76d8..0e98b951 100644
--- a/shared/symlink_target.h
+++ b/shared/symlink_target.h
@@ -8,8 +8,7 @@
#define SYMLINK_WIN_H_INCLUDED
#include "loki/ScopeGuard.h"
-#include <boost/scoped_array.hpp>
-#include "system_func.h"
+#include "last_error.h"
#include "string_conv.h"
#include "file_error.h"
#include "i18n.h"
@@ -64,19 +63,19 @@ namespace
//retrieve raw target data of symlink or junction
Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError)
{
- using ffs3::zToWx;
- using ffs3::FileError;
+ using zen::zToWx;
+ using zen::FileError;
#ifdef FFS_WIN
//FSCTL_GET_REPARSE_POINT: http://msdn.microsoft.com/en-us/library/aa364571(VS.85).aspx
try //reading certain symlinks requires admin rights! This shall not cause an error in user mode!
{
//allow access to certain symbolic links/junctions
- ffs3::Privileges::getInstance().ensureActive(SE_BACKUP_NAME); //throw (FileError)
+ zen::Privileges::getInstance().ensureActive(SE_BACKUP_NAME); //throw (FileError)
}
catch (...) {}
- const HANDLE hLink = ::CreateFile(ffs3::applyLongPathPrefix(linkPath).c_str(),
+ const HANDLE hLink = ::CreateFile(zen::applyLongPathPrefix(linkPath).c_str(),
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
@@ -85,31 +84,30 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError)
NULL);
if (hLink == INVALID_HANDLE_VALUE)
{
- wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + ffs3::zToWx(linkPath) + wxT("\"");
- throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted());
+ wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + zen::zToWx(linkPath) + wxT("\"");
+ throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted());
}
Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hLink);
(void)dummy; //silence warning "unused variable"
//respect alignment issues...
- const size_t bufferSize = REPARSE_DATA_BUFFER_HEADER_SIZE + MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
- boost::scoped_array<char> buffer(new char[bufferSize]);
+ std::vector<char> buffer(REPARSE_DATA_BUFFER_HEADER_SIZE + MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
DWORD bytesReturned; //dummy value required by FSCTL_GET_REPARSE_POINT!
if (!::DeviceIoControl(hLink, //__in HANDLE hDevice,
FSCTL_GET_REPARSE_POINT, //__in DWORD dwIoControlCode,
NULL, //__in_opt LPVOID lpInBuffer,
0, //__in DWORD nInBufferSize,
- buffer.get(), //__out_opt LPVOID lpOutBuffer,
- bufferSize, //__in DWORD nOutBufferSize,
+ &buffer[0], //__out_opt LPVOID lpOutBuffer,
+ static_cast<DWORD>(buffer.size()), //__in DWORD nOutBufferSize,
&bytesReturned, //__out_opt LPDWORD lpBytesReturned,
NULL)) //__inout_opt LPOVERLAPPED lpOverlapped
{
- wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + ffs3::zToWx(linkPath) + wxT("\"");
- throw FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted());
+ wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + zen::zToWx(linkPath) + wxT("\"");
+ throw FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted());
}
- REPARSE_DATA_BUFFER& reparseData = *reinterpret_cast<REPARSE_DATA_BUFFER*>(buffer.get()); //REPARSE_DATA_BUFFER needs to be artificially enlarged!
+ REPARSE_DATA_BUFFER& reparseData = *reinterpret_cast<REPARSE_DATA_BUFFER*>(&buffer[0]); //REPARSE_DATA_BUFFER needs to be artificially enlarged!
Zstring output;
if (reparseData.ReparseTag == IO_REPARSE_TAG_SYMLINK)
@@ -124,7 +122,7 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError)
}
else
{
- wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + ffs3::zToWx(linkPath) + wxT("\"");
+ wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + zen::zToWx(linkPath) + wxT("\"");
throw FileError(errorMessage + wxT("\n\n") + wxT("Not a symbolic link or junction!"));
}
@@ -142,7 +140,7 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError)
if (bytesWritten < 0 || bytesWritten >= BUFFER_SIZE)
{
wxString errorMessage = wxString(_("Error resolving symbolic link:")) + wxT("\n\"") + zToWx(linkPath) + wxT("\"");
- if (bytesWritten < 0) errorMessage += wxString(wxT("\n\n")) + ffs3::getLastErrorFormatted();
+ if (bytesWritten < 0) errorMessage += wxString(wxT("\n\n")) + zen::getLastErrorFormatted();
throw FileError(errorMessage);
}
buffer[bytesWritten] = 0; //set null-terminating char
bgstack15