Esempio n. 1
0
void DownloadOperation::changeFileToDownload(FileInfoList *toDownload)
{
  m_toCopy = toDownload;

  getRemotePath(m_toCopy, m_pathToSourceRoot.getString(), &m_pathToSourceFile);
  getLocalPath(m_toCopy, m_pathToTargetRoot.getString(), &m_pathToTargetFile);
}
SavedStateInterface::SavedStateResult
LocalSavedStateInterface::getMostRecentSavedStateImpl(
    w_string_piece lookupCommitId) const {
  auto commitIds =
      scm_->getCommitsPriorToAndIncluding(lookupCommitId, maxCommits_);
  for (auto& commitId : commitIds) {
    auto path = getLocalPath(commitId);
    // We could return a path that no longer exists if the path is removed
    // (for example by saved state GC) after we check that the path exists
    // here, but before the client reads the state. We've explicitly chosen to
    // return the state without additional safety guarantees, and leave it to
    // the client to ensure GC happens only after states are no longer likely
    // to be used.
    if (w_path_exists(path.c_str())) {
      log(DBG, "Found saved state for commit ", commitId, "\n");
      SavedStateInterface::SavedStateResult result;
      result.commitId = commitId;
      result.savedStateInfo =
          json_object({{"local-path", w_string_to_json(path)},
                       {"commit-id", w_string_to_json(commitId)}});
      return result;
    }
  }
  SavedStateInterface::SavedStateResult result;
  result.commitId = w_string();
  result.savedStateInfo = json_object(
      {{"error", w_string_to_json("No suitable saved state found")}});
  return result;
}
Esempio n. 3
0
XML::XML(MAUtil::String filename)
{
	MAUtil::String file = getLocalPath()+filename;

	file += ".xml";

	fname = file;

	XML::file = maFileOpen(file.c_str(), MA_ACCESS_READ_WRITE);

	int res = maFileExists(XML::file);

	if(res == 1)
	{
		maFileTruncate(XML::file, 0);
	}
	else if(res == 0)
	{
		maFileCreate(XML::file);
	}
	else
	{
		maPanic(0, "Error on file creation.");
	}

	CreateRoot(filename);

	_ActivityIndicator = new WaitMessage("Please, wait...", "Saving data to file.");
}
void SettingsScreen::saveSettings() {
	//return;
	// Construct the filename.
	this->mScreen->initalizeHelper(mAppCodeBox->getText(), mAppUniqBox->getText(), Cloudbase::MD5(mAppPwdBox->getText()).hexdigest());
	return;

	MAUtil::String filename = getLocalPath() + SETTINGS_FILE_NAME;

	// Open the file handle.
	printf("Open '%s'\n", filename.c_str());
	MAHandle file = maFileOpen(filename.c_str(), MA_ACCESS_READ_WRITE);
	if(file < 0) {
		printf("Error opening file %i\n", file);
		return;
	}

	// If the file exists...
	int res = maFileExists(file);
	MAASSERT(res >= 0);
	if(res) {
		// Truncate it, deleting any old data.
		printf("Truncating file...\n");
		res = maFileTruncate(file, 0);
		MAASSERT(res == 0);
	} else {
		// Otherwise, create it.
		printf("Creating file...\n");
		res = maFileCreate(file);
		MAASSERT(res >= 0);
	}
	// In either case, we now have an empty file at our disposal.

	// Write some data.
	MAUtil::String settingsData = "";
	settingsData += mAppCodeBox->getText();
	settingsData += ",";
	settingsData += mAppUniqBox->getText();
	settingsData += ",";
	settingsData += Cloudbase::MD5(mAppPwdBox->getText()).hexdigest();

	//static const char data[] = strdup(settingsData.c_str());

	res = maFileWrite(file, settingsData.c_str(), settingsData.length());
	MAASSERT(res == 0);

	// Close the file.
	printf("Closing...\n");
	res = maFileClose(file);
	MAASSERT(res == 0);

	printf("Done.\n");
	this->loadSettings();
	//return true;
}
Esempio n. 5
0
void Subtitle::setFileName(const QString &name)
{
    if (priv->file_name == name)
        return;
    priv->url.clear();
    priv->raw_data.clear();
    priv->file_name = name;
    if (priv->file_name.startsWith("file:"))
        priv->file_name = getLocalPath(priv->file_name);
    emit fileNameChanged();
}
Esempio n. 6
0
//getFilePath will look for a valid data file in several places
void getFilePath(char path[], struct PState * pstate)
{
	if (!getArgPath(path, pstate)) {
		if ( ! getEnvPath(path)) {
			if ( ! getLocalPath(path)) {
				strcat(path, ITEMFILENAME);
			}
		}
	}
	if (! testPath(path)) {
		printf("Could not find a valid data file at %s\n", path);
		exit(EXIT_FAILURE);
	}
}
Esempio n. 7
0
	/**
	 * Init database connection.
	 */
	void DatabaseManager::init()
	{
		MAUtil::String path = getLocalPath() + DATABASE_NAME;
		printf("Database path: %s", path.c_str());
		mDatabase = maDBOpen(path.c_str());
		printf("mDatabase = %d", mDatabase);

		// Create table if not exists.

		char buffer[BUF_SIZE];
		sprintf(buffer, "CREATE TABLE IF NOT EXISTS %s (productid TEXT, date INTEGER)",
			TABLE_NAME);
		printf("create table query = %s", buffer);
		int result = maDBExecSQL(mDatabase, buffer);
	}
OnlineDataNode *OnlineDataManager::getOnlineNodeData(QString nodePath, QString id)
{
    OnlineDataManager::Provider provider = determineProvider(nodePath);

    QNetworkAccessManager *manager = getNetworkAccessManager(provider);

    if (provider == OnlineDataManager::OSF) {

        OnlineDataNodeOSF *nodeData = new OnlineDataNodeOSF(getLocalPath(nodePath), manager, id, this);
        nodeData->setPath(nodePath);
        return nodeData;
    }

    return NULL;
}
Esempio n. 9
0
::IceInternal::DispatchStatus
tfs::slice::Transfer::___getLocalPath(::IceInternal::Incoming&__inS, const ::Ice::Current& __current)
{
    __checkMode(::Ice::Normal, __current.mode);
    ::IceInternal::BasicStream* __is = __inS.is();
    ::IceInternal::BasicStream* __os = __inS.os();
    ::Ice::Long chunkid;
    __is->read(chunkid);
    try
    {
        ::std::string __ret = getLocalPath(chunkid, __current);
        __os->write(__ret);
    }
    catch(const ::tfs::slice::ChunkError& __ex)
    {
        __os->write(__ex);
        return ::IceInternal::DispatchUserException;
    }
    return ::IceInternal::DispatchOK;
}
Esempio n. 10
0
bool AVMuxer::setMedia(const QString &fileName)
{
    if (d->io) {
        delete d->io;
        d->io = 0;
    }
    d->file_orig = fileName;
    const QString url_old(d->file);
    d->file = fileName.trimmed();
    if (d->file.startsWith("mms:"))
        d->file.insert(3, 'h');
    else if (d->file.startsWith(kFileScheme))
        d->file = getLocalPath(d->file);
    d->media_changed = url_old != d->file;
    if (d->media_changed) {
        d->format_forced.clear();
    }
    // a local file. return here to avoid protocol checking. If path contains ":", protocol checking will fail
    if (d->file.startsWith(QChar('/')))
        return d->media_changed;
    // use MediaIO to support protocols not supported by ffmpeg
    int colon = d->file.indexOf(QChar(':'));
    if (colon >= 0) {
#ifdef Q_OS_WIN
        if (colon == 1 && d->file.at(0).isLetter())
            return d->media_changed;
#endif
        const QString scheme = colon == 0 ? "qrc" : d->file.left(colon);
        // supportedProtocols() is not complete. so try MediaIO 1st, if not found, fallback to libavformat
        d->io = MediaIO::createForProtocol(scheme);
        if (d->io) {
            d->io->setUrl(d->file);
        }
    }
    return d->media_changed;
}
void SettingsScreen::loadSettings() {
	MAUtil::String filename = getLocalPath() + SETTINGS_FILE_NAME;

	MAHandle file = maFileOpen(filename.c_str(), MA_ACCESS_READ);
	if(file < 0) {
		printf("Error opening file %i\n", file);
		return;
	}

	// Check if the file exists.
	int res = maFileExists(file);
	MAASSERT(res >= 0);
	if(!res) {
		printf("File does not exist.\n");
		maFileClose(file);
		return;
	}

	// Get the file size.
	int size = maFileSize(file);
	printf("Size: %i\n", size);
	MAASSERT(size >= 0);

	// Read the file data.
	static char data[200];
	MAASSERT(size < (int)sizeof(data));
	res = maFileRead(file, data, size);
	MAASSERT(res == 0);

	// Close the file.
	printf("Closing...\n");
	res = maFileClose(file);
	MAASSERT(res == 0);

	printf("Done.\n");

	MAUtil::String contents = data;

	printf("Loaded settings string %s", contents.c_str());

	if (contents.findFirstOf(',', 0) <= 0)
		return;

	int commaPosition = contents.findFirstOf(',', 0);
	MAUtil::String appCode = contents.substr(0, commaPosition);
	mAppCodeBox->setText(appCode);
	printf("app code: %s", appCode.c_str());

	int prevCommaPosition = commaPosition + 1;
	commaPosition = contents.findFirstOf(',', prevCommaPosition);
	MAUtil::String appUniq = contents.substr(prevCommaPosition, commaPosition-prevCommaPosition);
	mAppUniqBox->setText(appUniq);
	printf("app uniq: %s", appUniq.c_str());

	prevCommaPosition = commaPosition + 1;
	commaPosition = contents.findFirstOf(',', prevCommaPosition);
	MAUtil::String appPwd = contents.substr(prevCommaPosition, contents.length() - prevCommaPosition);
	//mAppPwdBox->setText(appPwd);
	printf("app pwd: %s", appPwd.c_str());

	//helper = CBHelper(appCode, appUniq);
	//helper.setPassword(appPwd);
	this->mScreen->initalizeHelper(appCode, appUniq, appPwd);
}
Esempio n. 12
0
	/**
	 * Constructor.
	 */
	FileUtil::FileUtil()
	{
		// Use the local path as the default
		// path for File APIs.
		setAppPath(getLocalPath());
	}
Esempio n. 13
0
	/**
	 * Extract the files in the file system bundle defined
	 * as the first resource in the resource file. Files are
	 * extracted to the root of the local file system on the
	 * device/emulator.
	 *
	 * This function is intended as a high-level way to
	 * extract files packaged in the standard way used in
	 * the HTML5 Project Template.
	 */
	bool FileUtil::extractLocalFiles()
	{
		return extractFileSystem(1, getLocalPath());
	}
Esempio n. 14
0
QString toLocal(const QString &fullPath)
{
    return getLocalPath(fullPath);
}