diff --git a/deps/tools/rpiConfigServer_src/Application.cpp b/deps/tools/rpiConfigServer_src/Application.cpp index fd300d8..88b584e 100644 --- a/deps/tools/rpiConfigServer_src/Application.cpp +++ b/deps/tools/rpiConfigServer_src/Application.cpp @@ -87,12 +87,14 @@ void Application::Set(wpi::StringRef appType, void Application::Upload(wpi::ArrayRef contents, std::function onFail) { wpi::StringRef filename; + bool text = false; if (m_appType == "upload-java") { filename = "/uploaded.jar"; } else if (m_appType == "upload-cpp") { filename = "/uploaded"; } else if (m_appType == "upload-python") { filename = "/uploaded.py"; + text = true; } else { wpi::SmallString<64> msg; msg = "cannot upload application type '"; @@ -137,7 +139,23 @@ void Application::Upload(wpi::ArrayRef contents, } // write contents and close file - wpi::raw_fd_ostream(fd, true) << contents; + wpi::raw_fd_ostream out(fd, true); + if (text) { + wpi::StringRef str(reinterpret_cast(contents.data()), + contents.size()); + // convert any Windows EOL to Unix + for (;;) { + size_t idx = str.find("\r\n"); + if (idx == wpi::StringRef::npos) break; + out << str.slice(0, idx) << '\n'; + str = str.slice(idx + 2, wpi::StringRef::npos); + } + out << str; + // ensure file ends with EOL + if (!str.empty() && str.back() != '\n') out << '\n'; + } else { + out << contents; + } } // terminate vision process so it reloads