Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Canonical Paths for Relative Paths Calculations #4211

Merged
merged 3 commits into from Mar 4, 2018
Merged
Changes from 2 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+6 −3
Diff settings

Always

Just for now

Copy path View file
@@ -225,9 +225,9 @@ bool ConfigManager::hasWorkingDir() const
}


void ConfigManager::setWorkingDir( const QString & _wd )
void ConfigManager::setWorkingDir( const QString & wd )
{
m_workingDir = ensureTrailingSlash( _wd );
m_workingDir = ensureTrailingSlash( QFileInfo( wd ).canonicalFilePath() );
}


Copy path View file
@@ -1415,7 +1415,8 @@ QString SampleBuffer::tryToMakeRelative( const QString & file )
{
if( QFileInfo( file ).isRelative() == false )
{
QString f = QString( file ).replace( QDir::separator(), '/' );
// Normalize the path
QString f = QFileInfo( file ).canonicalFilePath().replace( QDir::separator(), '/' );

// First, look in factory samples
// Isolate "samples/" from "data:/samples/"
@@ -40,8 +40,10 @@ private slots:

QString absPath = fi.absoluteFilePath();
QString relPath = "drums/kick01.ogg";
QString fuzPath = absPath.replace(relPath, "drums/.///kick01.ogg");

This comment has been minimized.

Copy link
@PhysSong

PhysSong Mar 4, 2018

Member

Current one won't work because this line modifies absPath. This one will work:

QString fuzPath = absPath;
fuzPath.replace(relPath, "drums/.///kick01.ogg");

This comment has been minimized.

Copy link
@tresf

tresf Mar 4, 2018

Author Member

Ah yes, forgot Strings are mutable in Qt. Thanks.

QCOMPARE(SampleBuffer::tryToMakeRelative(absPath), relPath);
QCOMPARE(SampleBuffer::tryToMakeAbsolute(relPath), absPath);
QCOMPARE(SampleBuffer::tryToMakeRelative(fuzPath), relPath);
}
} RelativePathTests;

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.