Skip to content

Commit

Permalink
Use QFile::encode to convert a QString containing a filename to a c-s…
Browse files Browse the repository at this point in the history
…tring. Mac expects Utf8 and *nix expects local8Bit. QFile will do the right thing for each platform and not mangle Mac non-ASCII filenames.

git-svn-id: http://svn.osgeo.org/qgis/trunk@5585 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
telwertowski committed Jul 12, 2006
1 parent 1a25348 commit 9712510
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/plugins/spit/qgsshapefile.cpp
Expand Up @@ -24,6 +24,7 @@
#include <fstream>
#include <cstdio>

#include <QFile>
#include <QProgressDialog>
#include <QString>
#include <QLabel>
Expand All @@ -45,7 +46,7 @@ QgsShapeFile::QgsShapeFile(QString name){
filename = name;
features = 0;
OGRRegisterAll();
ogrDataSource = OGRSFDriverRegistrar::Open((const char *) filename);
ogrDataSource = OGRSFDriverRegistrar::Open(QFile::encodeName(filename).constData());
if (ogrDataSource != NULL){
valid = true;
ogrLayer = ogrDataSource->GetLayer(0);
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrfactory.cpp
Expand Up @@ -52,7 +52,7 @@ void QgsOGRFactory::setURI(QString uri)
// make connection to the data source
std::cerr << "Data source uri is " << dataSourceURI << std::endl;
// try to open for read
ogrDS = OGRSFDriverRegistrar::Open((const char *) dataSourceURI, FALSE, &ogrDriver);
ogrDS = OGRSFDriverRegistrar::Open(QFile::encodeName(dataSourceURI).constData(), FALSE, &ogrDriver);
if(ogrDS != NULL)
{
#ifdef QGISDEBUG
Expand Down
4 changes: 2 additions & 2 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -89,11 +89,11 @@ QgsOgrProvider::QgsOgrProvider(QString const & uri)
QgsDebugMsg("Data source uri is " + uri);

// try to open for update
ogrDataSource = OGRSFDriverRegistrar::Open((const char *) uri.toLocal8Bit().data(), TRUE, &ogrDriver);
ogrDataSource = OGRSFDriverRegistrar::Open(QFile::encodeName(uri).constData(), TRUE, &ogrDriver);
if(ogrDataSource == NULL)
{
// try to open read-only
ogrDataSource = OGRSFDriverRegistrar::Open((const char *) uri.toLocal8Bit().data(),FALSE, &ogrDriver);
ogrDataSource = OGRSFDriverRegistrar::Open(QFile::encodeName(uri).constData(), FALSE, &ogrDriver);

//TODO Need to set a flag or something to indicate that the layer
//TODO is in read-only mode, otherwise edit ops will fail
Expand Down

0 comments on commit 9712510

Please sign in to comment.