1 karl 1.19 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.6 //
|
3 karl 1.19 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 mike 1.6 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 kumpf 1.11 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
12 mike 1.6 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
|
15 kumpf 1.11 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
16 mike 1.6 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
18 kumpf 1.11 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21 mike 1.6 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Mike Brasher (mbrasher@bmc.com)
27 //
|
28 mike 1.7 // Modified By: Rudy Schuet (rudy.schuet@compaq.com) 11/12/01
|
29 ramnath 1.9 // added nsk platform support
30 // Ramnath Ravindran (Ramnath.Ravindran@compaq.com) 03/21/2002
31 // replaced instances of "| ios::binary" with
32 // PEGASUS_OR_IOS_BINARY
|
33 mike 1.6 //
34 //%/////////////////////////////////////////////////////////////////////////////
|
35 mike 1.8
|
36 sage 1.12 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
37 #include <Pegasus/Common/Config.h>
38 #endif
39
40
|
41 mike 1.8 #include <fstream>
|
42 kumpf 1.13 #include <cctype> // for tolower()
|
43 kumpf 1.14 #include <cstring>
|
44 mike 1.6 #include "System.h"
45
|
46 kumpf 1.10 #include <Pegasus/Common/PegasusVersion.h>
47
|
48 mike 1.6 #if defined(PEGASUS_OS_TYPE_WINDOWS)
49 # include "SystemWindows.cpp"
50 #elif defined(PEGASUS_OS_TYPE_UNIX)
51 # include "SystemUnix.cpp"
|
52 mike 1.7 #elif defined(PEGASUS_OS_TYPE_NSK)
53 # include "SystemNsk.cpp"
|
54 mike 1.6 #else
55 # error "Unsupported platform"
56 #endif
|
57 mike 1.8
|
58 david 1.16 #if defined(PEGASUS_OS_OS400)
59 # include "OS400ConvertChar.h"
60 #endif
61
|
62 mike 1.8 PEGASUS_USING_STD;
63
64 PEGASUS_NAMESPACE_BEGIN
65
66 Boolean System::copyFile(const char* fromPath, const char* toPath)
67 {
|
68 ramnath 1.9 ifstream is(fromPath PEGASUS_IOS_BINARY);
69 ofstream os(toPath PEGASUS_IOS_BINARY);
|
70 mike 1.8
71 char c;
72
73 while (is.get(c))
74 {
75 if (!os.put(c))
76 return false;
77 }
78
79 return true;
|
80 kumpf 1.13 }
81
82 // ATTN: Move to platform-specific System implementation files and call
83 // strcasecmp where it is available.
84 Sint32 System::strcasecmp(const char* s1, const char* s2)
85 {
86 while (*s1 && *s2)
87 {
88 int r = tolower(*s1++) - tolower(*s2++);
89
90 if (r)
91 return r;
92 }
93
94 if (*s2)
95 return -1;
96 else if (*s1)
97 return 1;
98
99 return 0;
|
100 mike 1.8 }
101
|
102 tony 1.15 // Return the just the file name from the path into basename
103 char *System::extract_file_name(const char *fullpath, char *basename)
104 {
105 char *p;
106 char buff[2048];
107 if (fullpath == NULL)
108 {
109 basename[0] = '\0';
110 return basename;
111 }
112 strcpy(buff, fullpath);
113 for(p = buff + strlen(buff); p >= buff; p--)
114 {
115 if (*p == '\\' || *p == '/')
116 {
117 strcpy(basename, p+1);
118 return basename;
119 }
120 }
121 strcpy(basename, fullpath);
122 return basename;
123 tony 1.15 }
124
125 // Return the just the path to the file name into dirname
126 char *System::extract_file_path(const char *fullpath, char *dirname)
127 {
128 char *p;
129 char buff[2048];
130 if (fullpath == NULL)
131 {
132 dirname[0] = '\0';
133 return dirname;
134 }
135 strcpy(buff, fullpath);
136 for(p = buff + strlen(buff); p >= buff; p--)
137 {
138 if (*p == '\\' || *p == '/')
139 {
140 strncpy(dirname, buff, p+1 - buff);
141 dirname[p+1 - buff] = '\0';
142 return dirname;
143 }
144 tony 1.15 }
145 strcpy(dirname, fullpath);
146 return dirname;
147 }
148
|
149 tony 1.17 // System ID constants for Logger::put and Logger::trace
150 const String System::CIMLISTENER = "cimlistener"; // Listener systme ID
151
|
152 mike 1.8 PEGASUS_NAMESPACE_END
|