wxString Instance::ReadVersionFile() { if (!GetVersionFile().FileExists()) return _(""); // Open the file for reading wxFSFile *vFile = wxFileSystem().OpenFile(GetVersionFile().GetFullPath(), wxFS_READ); wxString retVal; wxStringOutputStream outStream(&retVal); outStream.Write(*vFile->GetStream()); wxDELETE(vFile); return retVal; }
int64_t Instance::ReadVersionFile() { int64_t number = -1; if (!GetVersionFile().FileExists()) return number; // Open the file for reading wxFFileInputStream input( GetVersionFile().GetFullPath() ); if(input.IsOk()) { auto len = input.GetLength(); char * buf = new char[len]; input.Read(buf, len); std::istringstream in(buf); in >> number; delete[] buf; }
void Instance::WriteVersionFile(const wxString &contents) { if (!GetBinDir().DirExists()) GetBinDir().Mkdir(); wxFile vFile; if (!vFile.Create(GetVersionFile().GetFullPath(), true)) return; wxFileOutputStream outStream(vFile); wxStringInputStream inStream(contents); outStream.Write(inStream); }
nsresult ProcessUpdates(nsIFile *greDir, nsIFile *appDir, nsIFile *updRootDir, int argc, char **argv, const char *&appVersion) { nsresult rv; nsCOMPtr<nsIFile> updatesDir; rv = updRootDir->Clone(getter_AddRefs(updatesDir)); if (NS_FAILED(rv)) return rv; rv = updatesDir->AppendNative(NS_LITERAL_CSTRING("updates")); if (NS_FAILED(rv)) return rv; rv = updatesDir->AppendNative(NS_LITERAL_CSTRING("0")); if (NS_FAILED(rv)) return rv; PRBool exists; rv = updatesDir->Exists(&exists); if (NS_FAILED(rv) || !exists) return rv; nsCOMPtr<nsILocalFile> statusFile; if (GetStatusFile(updatesDir, statusFile) && IsPending(statusFile)) { nsCOMPtr<nsILocalFile> versionFile; // Remove the update if the update application version file doesn't exist // or if the update's application version is less than the current // application version. if (!GetVersionFile(updatesDir, versionFile) || IsOlderVersion(versionFile, appVersion)) { updatesDir->Remove(PR_TRUE); } else { ApplyUpdate(greDir, updatesDir, statusFile, appDir, argc, argv); } } return NS_OK; }