vfs: check userland buffers before reading them.
[haiku.git] / src / preferences / network / NetworkProfile.cpp
blobb92ddce2315b2620081a7c6d1b3b8cd75db70087
1 /*
2 * Copyright 2004-2015 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <NetworkProfile.h>
9 #include <stdlib.h>
12 using namespace BNetworkKit;
15 BNetworkProfile::BNetworkProfile()
17 fIsDefault(false),
18 fIsCurrent(false),
19 fName(NULL)
24 BNetworkProfile::BNetworkProfile(const char* path)
26 fIsDefault(false),
27 fIsCurrent(false)
29 SetTo(path);
33 BNetworkProfile::BNetworkProfile(const entry_ref& ref)
35 fIsDefault(false),
36 fIsCurrent(false)
38 SetTo(ref);
42 BNetworkProfile::BNetworkProfile(const BEntry& entry)
44 fIsDefault(false),
45 fIsCurrent(false)
47 SetTo(entry);
51 BNetworkProfile::~BNetworkProfile()
56 status_t
57 BNetworkProfile::SetTo(const char* path)
59 status_t status = fEntry.SetTo(path, true);
60 if (status != B_OK)
61 return status;
63 fPath.Unset();
64 fName = NULL;
65 return B_OK;
69 status_t
70 BNetworkProfile::SetTo(const entry_ref& ref)
72 status_t status = fEntry.SetTo(&ref);
73 if (status != B_OK)
74 return status;
76 fPath.Unset();
77 fName = ref.name;
78 return B_OK;
82 status_t
83 BNetworkProfile::SetTo(const BEntry& entry)
85 fEntry = entry;
86 fPath.Unset();
87 fName = NULL;
88 return B_OK;
92 const char*
93 BNetworkProfile::Name()
95 if (fName == NULL) {
96 if (fEntry.GetPath(&fPath) == B_OK)
97 fName = fPath.Leaf();
100 return fName;
104 status_t
105 BNetworkProfile::SetName(const char* name)
107 return B_OK;
111 bool
112 BNetworkProfile::Exists()
114 return fEntry.Exists();
118 status_t
119 BNetworkProfile::Delete()
121 return B_ERROR;
125 bool
126 BNetworkProfile::IsDefault()
128 return fIsDefault;
132 bool
133 BNetworkProfile::IsCurrent()
135 return fIsCurrent;
139 status_t
140 BNetworkProfile::MakeCurrent()
142 return B_ERROR;
146 // #pragma mark -
149 BNetworkProfile*
150 BNetworkProfile::Default()
152 return NULL;
156 BNetworkProfile*
157 BNetworkProfile::Current()
159 return NULL;