Example usage for com.badlogic.gdx.files FileHandle mkdirs

List of usage examples for com.badlogic.gdx.files FileHandle mkdirs

Introduction

In this page you can find the example usage for com.badlogic.gdx.files FileHandle mkdirs.

Prototype

public void mkdirs() 

Source Link

Usage

From source file:com.agateau.utils.FileUtils.java

License:Apache License

public static FileHandle getCacheDir() {
    FileHandle handle;
    if (PlatformUtils.isDesktop()) {
        handle = Gdx.files.external(".cache/" + appName);
    } else {//from   w  w w . j  av  a  2s .c om
        if (!Gdx.files.isExternalStorageAvailable()) {
            return null;
        }
        handle = Gdx.files.absolute(Gdx.files.getExternalStoragePath() + "/" + appName);
    }
    handle.mkdirs();
    return handle;
}

From source file:com.kotcrab.vis.editor.module.editor.PluginFilesAccessModule.java

License:Apache License

public FileHandle getPluginFolder(String pluginName) {
    FileHandle folder = pluginFolder.child(pluginName);
    folder.mkdirs();
    return folder;
}

From source file:com.kotcrab.vis.editor.module.editor.ProjectIOModule.java

License:Apache License

private void backupProject(FileHandle dataFile, int oldVersionCode, AsyncTaskAdapter listener) {
    Project project = readProjectDataFile(dataFile);
    FileHandle backupRoot = project.getVisDirectory();
    FileHandle backupOut = backupRoot.child("modules").child(".conversionBackup");
    backupOut.mkdirs();

    FileHandle backupArchive = backupOut
            .child("before-conversion-from-" + oldVersionCode + "-to-" + App.VERSION_CODE + ".zip");

    AsyncTaskProgressDialog taskDialog = Async.startTask(stage, "Creating backup",
            new CreateProjectBackupAsyncTask(backupRoot, backupArchive));
    taskDialog.addListener(listener);//from www.j  a v  a  2s. c  o m
}

From source file:com.kotcrab.vis.editor.module.editor.ProjectIOModule.java

License:Apache License

public void createLibGDXProject(final ProjectLibGDX project) {
    AsyncTask task = new AsyncTask("ProjectCreator") {

        @Override//w  w  w . j  a  v  a2  s. c o  m
        public void doInBackground() {
            setMessage("Creating directory structure...");

            FileHandle projectRoot = Gdx.files.absolute(project.getRoot());
            FileHandle standardAssetsDir = project.getAssetOutputDirectory();
            FileHandle visDir = projectRoot.child("vis");
            FileHandle visAssetsDir = visDir.child("assets");

            visDir.mkdirs();
            visAssetsDir.mkdirs();

            createStandardAssetsDirs(visAssetsDir);
            visDir.child("modules").mkdirs();

            setProgressPercent(33);
            setMessage("Moving assets...");

            try {
                Files.walkFileTree(standardAssetsDir.file().toPath(),
                        new CopyFileVisitor(visAssetsDir.file().toPath()));
            } catch (IOException e) {
                failed(e.getMessage(), e);
                Log.exception(e);
            }

            setProgressPercent(66);
            setMessage("Saving project files...");

            FileHandle projectFile = visDir.child(PROJECT_FILE);
            saveProjectFile(project, projectFile);

            setProgressPercent(100);
            statusBar.setText("Project created!");

            executeOnGdx(() -> loadNewGeneratedProject(projectFile));
        }
    };

    Async.startTask(stage, "Creating project", task);
}

From source file:com.kotcrab.vis.editor.module.editor.ProjectIOModule.java

License:Apache License

public void createGenericProject(ProjectGeneric project) {
    AsyncTask task = new AsyncTask("ProjectCreator") {

        @Override/*  w  w w.j  a va  2  s  .  c  om*/
        public void doInBackground() {
            setMessage("Creating directory structure...");

            FileHandle visDir = project.getVisDirectory();
            FileHandle visAssetsDir = visDir.child("assets");

            visDir.mkdirs();
            visAssetsDir.mkdirs();

            createStandardAssetsDirs(visAssetsDir);
            visDir.child("modules").mkdirs();

            setProgressPercent(50);
            setMessage("Saving project files...");

            FileHandle projectFile = visDir.child(PROJECT_FILE);
            saveProjectFile(project, projectFile);

            setProgressPercent(100);
            statusBar.setText("Project created!");

            executeOnGdx(() -> loadNewGeneratedProject(projectFile));
        }
    };

    Async.startTask(stage, "Creating project", task);
}

From source file:com.kotcrab.vis.editor.module.editor.VisTwitterReader.java

License:Apache License

@Override
public void init() {
    kryo = new Kryo();
    kryo.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
    kryo.register(Array.class, new ArraySerializer());

    FileHandle apiCache = fileAccess.getCacheFolder().child("twitter");
    apiCache.mkdirs();
    twitterCacheFile = apiCache.child("viseditor.data");

    if (twitterCacheFile.exists())
        readCache();/* w  w w. j  a  v  a 2  s  .  c  o  m*/

    containerTable = new VisTable(false);

    statusesTable = new VisTable();
    statusesTable.left().top();

    scrollPane = new VisScrollPane(statusesTable);
    scrollPane.setOverscroll(false, true);
    scrollPane.setFlickScroll(false);
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollingDisabled(true, false);

    containerTable.add("@VisEditor");
    containerTable.add().expandX().fillX();
    containerTable.add(new LinkLabel("Open in Browser", URL)).row();
    containerTable.addSeparator().colspan(3).spaceBottom(4);
    containerTable.row();
    statusesCell = containerTable.add(new VisLabel("Loading...", Align.center)).colspan(3).expand().fill();

    if (twitterCache == null || twitterCache.isOutdated()) {
        updateCache();
    } else {
        Log.debug("Twitter cache is up to date");
        buildTwitterTable(twitterCache);
    }
}

From source file:com.kotcrab.vis.editor.module.editor.WebAPIModule.java

License:Apache License

@Override
public void init() {
    webApiClient = new WebAPIClient();

    FileHandle apiCache = fileAccess.getCacheFolder().child("api");
    apiCache.mkdirs();

    contentCacheFile = apiCache.child("content.json");

    content = new ContentSet();

    json = new Json();
    json.setIgnoreUnknownFields(true);/*from w w  w .j a v  a  2 s .  c  om*/

    try {
        if (contentCacheFile.exists())
            content = json.fromJson(ContentSet.class, contentCacheFile);
    } catch (SerializationException ignored) { //no big deal if cache can't be loaded
    }

    refresh();
}

From source file:com.kotcrab.vis.editor.module.project.AssetsAnalyzerModule.java

License:Apache License

private FileHandle getNewTransactionBackup() {
    FileHandle dir;

    do {//from  w  ww .j  a v  a  2s.  co m
        dir = transactionBackupRoot.child("transaction-" + MathUtils.random(1000000000));
    } while (dir.exists());

    dir.mkdirs();

    return dir;
}

From source file:com.kotcrab.vis.editor.module.project.FileAccessModule.java

License:Apache License

public FileHandle getModuleFolder(String moduleName) {
    FileHandle moduleFolder = modulesFolder.child(moduleName);
    if (modulesFolder.exists() == false)
        moduleFolder.mkdirs();
    return moduleFolder;
}

From source file:com.kotcrab.vis.editor.siteapi.SiteAPIModule.java

License:Apache License

@Override
public void init() {
    siteApiClient = new SiteAPIClient();

    FileHandle apiCache = Gdx.files.absolute(App.APP_FOLDER_PATH).child("cache").child("api");
    apiCache.mkdirs();

    contentCacheFile = apiCache.child("content.json");
    gdxCacheFile = apiCache.child("gdx.json");
    versionCacheFile = apiCache.child("version.json");

    content = new ContentSet();
    gdx = new GdxReleaseSet();
    version = new VersionSet();

    json = new Json();
    json.setIgnoreUnknownFields(true);/*from  w ww.ja va2 s  .  co  m*/

    try {
        if (contentCacheFile.exists())
            content = json.fromJson(ContentSet.class, contentCacheFile);
    } catch (SerializationException ignored) { //no big deal if cache can't be loaded
    }

    try {
        if (gdxCacheFile.exists())
            gdx = json.fromJson(GdxReleaseSet.class, gdxCacheFile);
    } catch (SerializationException ignored) {
    }

    try {
        if (versionCacheFile.exists())
            version = json.fromJson(VersionSet.class, versionCacheFile);
    } catch (SerializationException ignored) {
    }

    refresh();
}