mirror of
https://github.com/Toastconcern/FrameStudio.git
synced 2026-10-29 00:02:23 +01:00
CI stamps every Studio build with its commit (FRAME_BUILD) and the release gets latest.json: the commit, Frame Home's identity (a hash of the headset programs in frame/payload) and the files in the release. Frame Studio (studio/updater.h): checks a few seconds after start and every 6 hours (Help > Check for Updates any time). A newer build shows "Update Available" in the top bar; Download and Install fetches this computer's build with the system's curl, unpacks it with tar, and swaps each item in (the old one renamed aside first, so the running copy keeps working and a failure rolls everything back). Restart Now closes through the normal unsaved-changes prompt, then starts the new copy; the next start deletes what was set aside. Local builds never update. New platform calls: systemTool (System32's curl/tar on Windows) and launch. Frame Home (src/switcher.cpp): on the Steam Frame the Environments panel checks a minute after it starts and every 6 hours. When the installed programs' hash isn't the release's, "Update Frame Home" shows beside Restart Frame Home; it downloads FrameHome-installer.zip and runs its install.sh in its own session (which restarts Frame Home and the panel), and the new panel says "Frame Home is updated". Also frame-switcher --check-update / --update from a terminal. frame/payload: frame-switcher rebuilt on the Steam Frame with this. Tested: Studio's full cycle (check, download, unpack, swap, relaunch, cleanup) and its rollback against a local fake release on Windows; the headset's check and update against a fake release on the Frame (old panel and Frame Home replaced, then up to date); Linux compile of Studio; Studio --selftest unchanged (98 passed, same 6 known fails). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
3.2 KiB
C++
61 lines
3.2 KiB
C++
#pragma once
|
|
// What Frame Studio needs from the operating system, behind one interface: platform_win32.cpp (Windows) and
|
|
// platform_posix.cpp (Linux, macOS). Text and paths cross it as UTF-8 std::string (or fs::path); the rest of Studio
|
|
// never includes a system header.
|
|
#include <cstdio>
|
|
#include <ctime>
|
|
#include <filesystem>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace platform {
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
// ── Text ──
|
|
std::wstring widen(const std::string& utf8);
|
|
std::string narrow(const std::wstring& wide);
|
|
|
|
// ── Places ──
|
|
fs::path exeDir(); // the folder Frame Studio runs from (the Frame payload ships beside it)
|
|
fs::path userDataDir(); // %APPDATA% / $XDG_DATA_HOME (~/.local/share) / ~/Library/Application Support
|
|
fs::path documentsDir(); // Documents (the user's own; ~ when there's none)
|
|
FILE* openFile(const fs::path& path, const char* mode); // fopen with a Unicode path everywhere
|
|
std::tm localTime(std::time_t t); // (thread-safe localtime)
|
|
|
|
// ── Other programs ──
|
|
// Runs a command line (no console window); stdout and stderr land in `out`. Returns its exit code (-1: not started).
|
|
// The line is in the platform's shell syntax as far as quoting goes: "double quotes" around arguments work on both.
|
|
int run(const std::string& commandLine, const fs::path& workingDir, std::string& out);
|
|
// ssh / scp, ready to prefix arguments: quoted when it's a path, with a trailing space.
|
|
std::string sshTool(const char* name);
|
|
// The system's own curl / tar (Windows 10 and later ship both in System32; Git's tar there can't open a .zip), ready
|
|
// to prefix arguments like sshTool.
|
|
std::string systemTool(const char* name);
|
|
// Opens a folder in the file browser, or a file / URL in its usual program.
|
|
void openPath(const std::string& pathOrUrl);
|
|
// Starts a program (or, on macOS, a .app) on its own: not waited for, it outlives Frame Studio. False: not started.
|
|
bool launch(const fs::path& program);
|
|
|
|
// ── Dialogs ── (modal; they block until answered)
|
|
// The window dialogs belong to (Windows: its HWND), so they come up over it. Null: none.
|
|
void setDialogOwner(void* nativeWindow);
|
|
enum class Icon { Info, Warning, Error, Question };
|
|
void message(const std::string& title, const std::string& text, Icon icon = Icon::Info);
|
|
enum class Answer { Yes, No, Cancel };
|
|
Answer ask(const std::string& title, const std::string& text, bool withCancel, Icon icon = Icon::Question);
|
|
|
|
// One line of a file dialog's type list: "Meta home" with {"*.apk"}. "All files" is always added after them.
|
|
struct FileFilter {
|
|
std::string description;
|
|
std::vector<std::string> patterns;
|
|
};
|
|
// The files picked (empty: cancelled). `multiple`: several may be picked at once.
|
|
std::vector<std::string> openFiles(const std::string& title, const std::vector<FileFilter>& filters, bool multiple);
|
|
// Where to save (empty: cancelled). `suggestedName` is filled in; `extension` ("fenv", no dot) is added to a name
|
|
// typed without one. Asks before replacing a file that exists.
|
|
std::string saveFile(const std::string& title, const std::string& suggestedName, const std::vector<FileFilter>& filters,
|
|
const std::string& extension);
|
|
|
|
} // namespace platform
|