本文整理汇总了C++中Directory::Location方法的典型用法代码示例。如果您正苦于以下问题:C++ Directory::Location方法的具体用法?C++ Directory::Location怎么用?C++ Directory::Location使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Directory
的用法示例。
在下文中一共展示了Directory::Location方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
void Settings::Load()
{
Directory appDataDir = GetAppDataDir();
if (appDataDir.Exists())
{
File config;
config.SetLocation(appDataDir.Location().OriginalString() + "/config.txt");
FileStream fs;
if (config.Exists())
{
AutoPointerArray<UInt8> buf(new UInt8[config.Size()], config.Size());
if (fs.Open(config.Location(), FileAccessMode::Read, FileAccessPriority::ReadThroughput))
{
fs.Read(buf.Get(), 0, buf.Size());
fs.Close();
for (Size i = 0, s = 0; i < buf.Size(); ++i)
if (buf[i] == '\n')
{
String line = String(reinterpret_cast<const char*>(&buf[s]), i - s);
AutoPointerArray<String> keyValue = line.Split(String("="));
if (keyValue.Count() == 2)
{
const char* key = StringCache::Find(keyValue[0]);
if (key == 0)
key = keyValue[0].c_str();
m_PImpl->m_Data[key] = keyValue[1];
}
s = i+1;
}
}
}
}
}
示例2: Save
void Settings::Save()
{
Directory appDataDir = GetAppDataDir();
if (!appDataDir.Exists())
appDataDir.CreateNewDirectory();
auto it = m_PImpl->m_Data.Begin();
auto end = m_PImpl->m_Data.End();
File config;
config.SetLocation(appDataDir.Location().OriginalString() + "/config.txt");
config.CreateNewFile();
FileStream fs;
if (fs.Open(config.Location(), FileAccessMode::Write, FileAccessPriority::DelayReadWrite))
{
for (; it != end; ++it)
{
String buf = String::UnsafeStringCreation(it->first) + "=" + it->second + "\n";
fs.Write(reinterpret_cast<const UInt8*>(buf.c_str()), 0, buf.Length());
}
fs.Close();
}
}