Skip to content

Commit

Permalink
[core/win32] Fix trailing backslash causing probem with some version …
Browse files Browse the repository at this point in the history
…of gcc
  • Loading branch information
mean committed Nov 17, 2016
1 parent b4ef66a commit e58bcf0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 9 additions & 7 deletions avidemux_core/ADM_core/src/ADM_folder_win32.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/***************************************************************************
copyright : (C) 2006 by mean
email : fixounet@free.fr
***************************************************************************/
Expand Down Expand Up @@ -89,7 +89,7 @@ char *ADM_getInstallRelativePath(const char *base1, const char *base2, const cha
wideCharStringToUtf8(wcModuleName, -1, moduleName);

char *slash = strrchr(moduleName, '\\');

if (slash)
*slash = '\0';

Expand Down Expand Up @@ -559,8 +559,10 @@ const std::string ADM_getFileName(const std::string &str)
{
size_t idx=str.find_last_of ("\\");
size_t idx2=str.find_last_of ("/");

// no / nor \


// no / nor \
if(idx2==std::string::npos && idx==std::string::npos)
return str;
// Both, take the further one
Expand All @@ -569,7 +571,7 @@ const std::string ADM_getFileName(const std::string &str)
return str.substr(idx2+1);
else
return str.substr(idx+1);

// Only one found
if(idx2!=std::string::npos)
return str.substr(idx2+1);
Expand All @@ -586,10 +588,10 @@ uint8_t ADM_renameFile(const char *source, const char *target)
int targetFileNameLength = utf8StringToWideChar(target, -1, NULL);
wchar_t wcFileSource[sourceFileNameLength];
wchar_t wcFileTarget[targetFileNameLength];

utf8StringToWideChar(source, -1, wcFileSource);
utf8StringToWideChar(target, -1, wcFileTarget);

if(!_wrename(wcFileSource,wcFileTarget)) return true;
ADM_error("Failed to rename %s to %s\n",source,target);
return false;
Expand Down
10 changes: 5 additions & 5 deletions avidemux_core/ADM_core/src/ADM_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,16 +529,16 @@ std::string utf8StringToAnsi(const char *utf8String)
dupe.reserve(original.length());
std::string::size_type xlastPos = 0;
std::string::size_type findPos;
while( std::string::npos != ( findPos = original.find( "/""", xlastPos )))
std::string to=std::string("\\\\");
while( std::string::npos != ( findPos = original.find( "/", xlastPos )))
{
dupe.append( original, xlastPos, findPos - xlastPos );
dupe += std::string("\\");
dupe += to;
xlastPos = findPos + 1;
}
dupe += original.substr( xlastPos );

std::string fileName=ADM_getFileName(dupe);
std::string pathName=ADM_extractPath(dupe);
std::string fileName=ADM_getFileName(dupe);
std::string pathName=ADM_extractPath(dupe);



Expand Down

0 comments on commit e58bcf0

Please sign in to comment.