Skip to content
Permalink
Browse files
Use QFile::encode to convert a QString containing a filename to a c-s…
…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/qgis@5585 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
telwertowski committed Jul 12, 2006
1 parent 0ba6163 commit 86a2a2196805ba46661c332d44ee75aac1b9368a
Showing with 5 additions and 4 deletions.
  1. +2 −1 src/plugins/spit/qgsshapefile.cpp
  2. +1 −1 src/providers/ogr/qgsogrfactory.cpp
  3. +2 −2 src/providers/ogr/qgsogrprovider.cpp
@@ -24,6 +24,7 @@
#include <fstream>
#include <cstdio>

#include <QFile>
#include <QProgressDialog>
#include <QString>
#include <QLabel>
@@ -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);
@@ -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
@@ -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

0 comments on commit 86a2a21

Please sign in to comment.