ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/Spectre/Mounter.cpp
(Generate patch)

Comparing trunk/Spectre/Mounter.cpp (file contents):
Revision 173 by douglas, 2003-06-28T21:35:25-07:00 vs.
Revision 174 by douglas, 2003-06-29T01:53:27-07:00

# Line 4 | Line 4
4   //
5   // Mounter.cpp
6  
7 + #include "Mounter.h"
8 +
9   #ifdef _FreeBSD_
10 + #include <cctype>
11   #include <fcntl.h>
9 #endif
12  
13 < #include "Mounter.h"
13 > inline string toupper(const string& lower)
14 > {
15 >        string upper;
16 >
17 >        for (unsigned index = 0; index < lower.length(); index++)
18 >        {
19 >                upper += toupper(lower[index]);
20 >        }
21 >
22 >        return upper;
23 > }
24 > #endif
25  
26   void Mounter::mount()
27   {
# Line 158 | Line 171 | void Mounter::mount(const string& folder
171          
172          string smb = "//" + host + "/" + folder;
173   #elif defined _FreeBSD_
174 <        char* credentials = "~/.nsmbrc";
175 <
174 >        char* credentials = new char[strlen(getenv("HOME")) + 9];
175 >        
176 >        sprintf(credentials, "%s/.nsmbrc", getenv("HOME"));
177          int dot = open(credentials, O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
178          close(dot);
179  
180          ofstream fout(credentials);
181  
182 <        fout << "[default]\n"
182 >        fout << "[" << toupper(host) << ":" << toupper(owner) << "]\n"
183                  << "password=" << password(owner) << "\n";
184  
185          fout.close();
# Line 207 | Line 221 | void Mounter::mount(const string& folder
221          mount.close();
222  
223          unlink(credentials);
224 + #ifdef _FreeBSD_
225 +        delete [] credentials;
226 + #endif
227   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines