forked from premiere/premiere-libtorrent
use UNC paths on windows by default
This commit is contained in:
parent
6c395cedee
commit
14287b8a7b
|
@ -180,6 +180,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_USE_GETADAPTERSADDRESSES 1
|
||||
#define TORRENT_HAS_SALEN 0
|
||||
#define TORRENT_USE_GETIPFORWARDTABLE 1
|
||||
#define TORRENT_USE_UNC_PATHS 1
|
||||
|
||||
// ==== WINDOWS ===
|
||||
#elif defined WIN32
|
||||
|
@ -196,6 +197,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#endif
|
||||
#define TORRENT_USE_RLIMIT 0
|
||||
#define TORRENT_HAS_FALLOCATE 0
|
||||
#define TORRENT_USE_UNC_PATHS 1
|
||||
|
||||
// ==== SOLARIS ===
|
||||
#elif defined sun || defined __sun
|
||||
|
@ -358,6 +360,10 @@ inline int snprintf(char* buf, int len, char const* fmt, ...)
|
|||
#define TORRENT_COMPLETE_TYPES_REQUIRED 0
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_USE_UNC_PATHS
|
||||
#define TORRENT_USE_UNC_PATHS 0
|
||||
#endif
|
||||
|
||||
#ifndef TORRENT_USE_RLIMIT
|
||||
#define TORRENT_USE_RLIMIT 1
|
||||
#endif
|
||||
|
|
|
@ -809,6 +809,10 @@ namespace libtorrent
|
|||
m_path = convert_to_native(path);
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_UNC_PATHS
|
||||
m_path = "\\\\?\\" + m_path;
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT((mode & rw_mask) < sizeof(mode_array)/sizeof(mode_array[0]));
|
||||
open_mode_t const& m = mode_array[mode & rw_mask];
|
||||
DWORD a = attrib_array[(mode & attribute_mask) >> 12];
|
||||
|
|
|
@ -220,6 +220,28 @@ namespace libtorrent
|
|||
for (char const* e = split.c_str(); e != 0; e = next_path_element(e))
|
||||
{
|
||||
std::string pe = e;
|
||||
#if !TORRENT_USE_UNC_PATHS && defined TORRENT_WINDOWS
|
||||
// if we're not using UNC paths on windows, there
|
||||
// are certain filenames we're not allowed to use
|
||||
const static char const* reserved_names[] =
|
||||
{
|
||||
"con", "prn", "aux", "clock$", "nul",
|
||||
"com0", "com1", "com2", "com3", "com4",
|
||||
"com5", "com6", "com7", "com8", "com9",
|
||||
"lpt0", "lpt1", "lpt2", "lpt3", "lpt4",
|
||||
"lpt5", "lpt6", "lpt7", "lpt8", "lpt9"
|
||||
};
|
||||
int num_names = sizeof(reserved_names)/sizeof(reserved_names[0]);
|
||||
|
||||
char const* file_end = strrchr(pe.c_str(), '.');
|
||||
std::string name(pe.c_str(), file_end);
|
||||
std::transform(name.begin(), name.end(), name.begin(), &to_lower);
|
||||
char const* str = std::find(reserved_names, reserved_names + num_names, name);
|
||||
if (str != reserved + num_names)
|
||||
{
|
||||
pe += "_";
|
||||
}
|
||||
#endif
|
||||
if (!valid_path_element(pe)) continue;
|
||||
trim_path_element(pe);
|
||||
new_path = combine_path(new_path, pe);
|
||||
|
|
Loading…
Reference in New Issue