Changeset View
Changeset View
Standalone View
Standalone View
source/ps/scripting/JSInterface_VFS.cpp
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | JS::Value JSI_VFS::ReadFileLines(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename) | ||||
// Fix CRLF line endings. (This function will only ever be used on text files.) | // Fix CRLF line endings. (This function will only ever be used on text files.) | ||||
contents.Replace("\r\n", "\n"); | contents.Replace("\r\n", "\n"); | ||||
// split into array of strings (one per line) | // split into array of strings (one per line) | ||||
std::stringstream ss(contents); | std::stringstream ss(contents); | ||||
JS::RootedValue line_array(cx); | JS::RootedValue line_array(cx); | ||||
scriptInterface.CreateArray(&line_array); | ScriptInterface::CreateArray(cx, &line_array); | ||||
std::string line; | std::string line; | ||||
int cur_line = 0; | int cur_line = 0; | ||||
while (std::getline(ss, line)) | while (std::getline(ss, line)) | ||||
{ | { | ||||
// Decode each line as UTF-8 | // Decode each line as UTF-8 | ||||
JS::RootedValue val(cx); | JS::RootedValue val(cx); | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator