diff --git a/cpp/src/ice2slice/Main.cpp b/cpp/src/ice2slice/Main.cpp index 98eedfd0b89..0858411eae6 100644 --- a/cpp/src/ice2slice/Main.cpp +++ b/cpp/src/ice2slice/Main.cpp @@ -112,7 +112,7 @@ compile(const vector& argv) bool preprocess = opts.isSet("E"); - string output = opts.optArg("output-dir"); + string outputDir = opts.optArg("output-dir"); bool debug = opts.isSet("debug"); @@ -194,9 +194,17 @@ compile(const vector& argv) DefinitionContextPtr dc = p->findDefinitionContext(p->topLevelFile()); assert(dc); + string baseName = icecpp->getBaseName(); + // Remove any directory components from the base name. + string::size_type pos = baseName.find_last_of("/\\"); + if (pos != string::npos) + { + baseName = baseName.substr(pos); + } + try { - Gen gen(icecpp->getBaseName()); + Gen gen(outputDir + baseName); gen.generate(p); } catch (const Slice::FileException& ex)