Пример #1
0
    std::string FS::readlink(std::string path) const
    {
        LowLevel::INode buf;
        if (!this->retrievePathToINode(path, buf))
            throw Exception::FileNotFound();

        if (buf.type == LowLevel::INodeType::INT_SYMLINK)
        {
            // Read the link information out of the file.
            FSFile* file = new FSFile(this->filesystem, this->stream, buf.inodeid);
            file->open(std::ios_base::in);
            char* buffer = (char*)malloc(buf.dat_len + 1);
            std::streamsize count = file->read(buffer, buf.dat_len);
            if (count < buf.dat_len)
                buffer[count] = '\0';
            else
                buffer[buf.dat_len] = '\0';
            std::string result = buffer;
            free(buffer);

            // Check to make sure it is valid.
            if (count != buf.dat_len)
                throw Exception::InternalInconsistency();
            
            return result;
        }
        else
            throw Exception::NotSupported();
    }
Пример #2
0
    void FS::symlink(std::string linkPath, std::string targetPath)
    {
        auto configuration = [&](LowLevel::INode& buf)
        {
        };
        this->performCreation(LowLevel::INodeType::INT_SYMLINK, linkPath, 0755, configuration);

        // We just created the file, so if this fails then
        // it's an internal inconsistency.
        LowLevel::INode buf;
        if (!this->retrievePathToINode(linkPath, buf))
            throw Exception::FileNotFound();
       
        try
        {
            FSFile f = this->filesystem->getFile(buf.inodeid);
            f.open();
            f.write(targetPath.c_str(), targetPath.length());
            f.close();
            if (f.fail() || f.bad())
                throw Exception::InternalInconsistency();
        }
        catch (...)
        {
            // Delete the file from disk since we failed to
            // write to it (at least in some manner).  Then
            // rethrow the exception.
            this->unlink(linkPath);
            throw;
        }
    }
Пример #3
0
    FSFile FS::open(std::string path)
    {
        this->ensurePathExists(path);

        LowLevel::INode buf;
        if (!this->retrievePathToINode(path, buf))
            throw Exception::FileNotFound();

        // Open the file and return it.
        FSFile file = this->filesystem->getFile(buf.inodeid);
        file.open();
        return file;
    }
Пример #4
0
    void FS::truncate(std::string path, off_t size)
    {
        if (size > MSIZE_FILE)
            throw Exception::FileTooBig();
        this->ensurePathExists(path);

        LowLevel::INode buf;
        if (!this->retrievePathToINode(path, buf))
            throw Exception::FileNotFound();
        this->touchINode(buf, "cma");
        this->saveINode(buf);

        // Truncate the file to the desired size.
        FSFile file = this->filesystem->getFile(buf.inodeid);
        file.open();
        file.truncate(size);
        file.close();
        if (file.fail() || file.bad())
            throw Exception::InternalInconsistency();
    }
Пример #5
0
void GameManager::init()
{
#ifdef CHOWDREN_USER_PROFILER
    user_log.open("log.txt", "w");
#endif

#ifdef CHOWDREN_USE_PROFILER
    PROFILE_SET_DAMPING(0.0);
#endif
    frame = &static_frames;

#ifdef CHOWDREN_IS_DEMO
    idle_timer_started = false;
    global_time = show_build_timer = reset_timer = manual_reset_timer = 0.0;
#endif

#ifdef CHOWDREN_USE_JOYTOKEY
    simulate_count = 0;
    axis_moved = false;
    last_axis = -1;
    deadzone = 0.4f;
    pad_selected = false;
    pad_disconnected = false;
    for (int i = 0; i < CHOWDREN_BUTTON_MAX-1; i++)
        key_mappings[i] = -1;
    for (int i = 0; i < CHOWDREN_AXIS_MAX-1; i++) {
        axis_pos_mappings[i] = -1;
        axis_neg_mappings[i] = -1;
        axis_values[i] = 0;
    }
#endif
    platform_init();
    media.init();
    set_window(false);

    // application setup
    preload_images();
    reset_globals();
    setup_keys(this);

    // setup random generator from start
    cross_srand((unsigned int)platform_get_global_time());

    fps_limit.start();
    set_framerate(FRAMERATE);

    int start_frame = 0;
#if defined(CHOWDREN_IS_AVGN)
    start_frame = 0;
#elif defined(CHOWDREN_IS_HFA)
    start_frame = 0;
#elif defined(CHOWDREN_IS_FP)
    player_died = false;
    lives = 3;
    start_frame = 0;
    // values->set(1, 2);
    // values->set(12, 2);
#elif defined(CHOWDREN_IS_NAH)
    platform_set_scale_type(2);
    // start_frame = 3;
    // set_local("fre");
    // values->set(13, 25);
    // strings->set(23, "OBJETS");
    // strings->set(9, "-fre");
#else
    start_frame = 0;
#endif

#ifdef NDEBUG
    set_frame(0);
#else
    set_frame(start_frame);
#endif
}