summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cs/Gen.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2006-01-30 04:11:45 +0000
committerMichi Henning <michi@zeroc.com>2006-01-30 04:11:45 +0000
commit179f9a587877580d06a9bec54ccd0c955c614c6c (patch)
tree89519d6c7f545404bc2063bc946e067bf0890f60 /cpp/src/slice2cs/Gen.cpp
parentfix for path with mixed separators (diff)
downloadice-179f9a587877580d06a9bec54ccd0c955c614c6c.tar.bz2
ice-179f9a587877580d06a9bec54ccd0c955c614c6c.tar.xz
ice-179f9a587877580d06a9bec54ccd0c955c614c6c.zip
Bug 838.
Diffstat (limited to 'cpp/src/slice2cs/Gen.cpp')
-rwxr-xr-xcpp/src/slice2cs/Gen.cpp53
1 files changed, 14 insertions, 39 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 986b98cf354..38a009798fd 100755
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -849,49 +849,24 @@ Slice::CsVisitor::emitAttributes(const ContainedPtr& p)
Slice::Gen::Gen(const string& name, const string& base, const vector<string>& includePaths, const string& dir,
bool impl, bool implTie, bool stream)
- : _base(base),
- _includePaths(includePaths),
+ : _includePaths(includePaths),
_stream(stream)
{
- string file = base + ".cs";
- string fileImpl = base + "I.cs";
+ string fileBase = base;
+ string::size_type pos = base.find_last_of("/\\");
+ if(pos != string::npos)
+ {
+ fileBase = base.substr(pos + 1);
+ }
+ string file = fileBase + ".cs";
+ string fileImpl = fileBase + "I.cs";
if(!dir.empty())
{
- //
- // Get the working directory and look at the returned path
- // to find out whether we need to use a forward or backward slash
- // as a path separator. (This seems to be one of the very few
- // portable ways to get the correct separator.)
- //
- char* p;
-#if defined(_MSC_VER)
- p = _getcwd(0, 0);
-#else
- p = getcwd(0, 0);
-#endif
- if(p == 0)
- {
- cerr << name << ": cannot get working directory: " << strerror(errno) << endl;
- return;
- }
- string cwd(p);
- string slash = cwd.find('/') == string::npos ? "\\" : "/";
- free(p);
-
- string::size_type pos = base.find_last_of("/\\");
- if(pos != string::npos)
- {
- string fileBase(base, pos + 1);
- file = dir + slash + fileBase + ".cs";
- fileImpl = dir + slash + fileBase + "I.cs";
- }
- else
- {
- file = dir + slash + file;
- fileImpl = dir + slash + fileImpl;
- }
+ file = dir + '/' + file;
+ fileImpl = dir + '/' + fileImpl;
}
+
_out.open(file.c_str());
if(!_out)
{
@@ -900,7 +875,7 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
}
printHeader();
- _out << nl << "// Generated from file `" << base << ".ice'";
+ _out << nl << "// Generated from file `" << fileBase << ".ice'";
_out << sp << nl << "using _System = System;";
_out << nl << "using _Microsoft = Microsoft;";
@@ -910,7 +885,7 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
struct stat st;
if(stat(fileImpl.c_str(), &st) == 0)
{
- cerr << name << ": `" << fileImpl << "' already exists - will not overwrite" << endl;
+ cerr << name << ": `" << fileImpl << "' already exists--will not overwrite" << endl;
return;
}
_impl.open(fileImpl.c_str());