本文整理汇总了C#中Lua.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Lua.ToString方法的具体用法?C# Lua.ToString怎么用?C# Lua.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lua
的用法示例。
在下文中一共展示了Lua.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FOpen
public static Stream FOpen(Lua.CharPtr cFilename, Lua.CharPtr cMode)
{
string filename = "/" + cFilename.ToString();
filename = filename.Replace("\\", "/").Replace("/./", "/");
filename = filename.Substring(1); // remove the leading slash again
bool read = true;
bool write = false;
bool truncate = false;
bool startAtEnd = false;
if (cMode.chars.Length != 0)
{
int pos = 0;
switch (cMode.chars[pos])
{
case 'r':
break;
case 'w':
read = false;
write = true;
truncate = true;
break;
case 'a':
read = false;
write = true;
startAtEnd = true;
break;
default:
throw new ArgumentException(string.Format("Bad mode character '{0}' at position {1} in mode '{2}'", cMode.chars[pos], pos, cMode.ToString()));
}
++pos;
if (cMode.chars[pos] == '+')
{
read = true;
write = true;
++pos;
}
if (cMode.chars[pos] == 'b')
{
// ignore
++pos;
}
if (cMode.chars[pos] != '\0')
{
throw new ArgumentException(string.Format("Bad mode character '{0}' at position {1} in mode '{2}'", cMode.chars[pos], pos, cMode.ToString()));
}
}
// Try to populate from Unity Resources, but don't bother if we're truncating
if (!truncate && !_fileSystem.ContainsKey(filename))
PopulateFromResource(filename);
// If we're not writing, we just use a read-only MemoryStream to access the data, allowing simultaneous reads
if (!write)
{
if (!_fileSystem.ContainsKey(filename))
{
throw new FileNotFoundException(string.Format("File not found - {0}", filename));
}
return new MemoryStream(_fileSystem[filename], false);
}
// Since we're writing we need to use a fancy derivative of MemoryStream that knows how to bake the data into
// the filesystem when it is disposed
var stream = new FileMemoryStream(filename, truncate, startAtEnd);
return stream;
}