beemdevelopment/Aegis · error · IOException

Unable to create directories

Error message

Unable to create directories: %s

What it means

importPack creates the per-pack directory (named from the pack's UUID and version) with File.mkdirs(). If the directory doesn't exist and mkdirs() returns false — typically a filesystem/permission problem or a name collision with an existing regular file — this IOException is thrown with the target directory path.

Solutions

  1. Check device storage is available and not full; retry the import
  2. Clear Aegis's cache/data for the icons directory or delete the conflicting file at the target path
  3. Remount or reinsert external storage if the SD card is read-only or missing
  4. Retry the import after rebooting the device
Defensive patterns

Strategy: try-catch

Validate before calling

File packDir = new File(iconsBaseDir, uuid);
if (packDir.exists() && !packDir.isDirectory()) {
    throw new IconPackException("Conflicting file at " + packDir);
}
if (!packDir.getCanonicalFile().toPath().startsWith(iconsBaseDir.getCanonicalFile().toPath())) {
    throw new IconPackException("Unsafe path");
}

Try / catch

try {
    iconPackManager.importPack(file);
} catch (IconPackException e) {
    UiHelper.showDialog(context, R.string.import_error_storage);
}

Prevention

When it happens

Trigger: packDir.mkdirs() returning false during importPack: the app's external storage is unavailable/read-only, a file (not directory) already exists at the target path, or the filesystem is full.

Common situations: SD card mounted as read-only or removed mid-import; leftover file from a previously failed import occupying the UUID-based path; storage full on device.

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


AI-assisted analysis of beemdevelopment/Aegis@d6f4e5925a (2026-09-08). Data as JSON: /api/errors/a690d821ca367f39. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/com/beemdevelopment/aegis/icons/IconPackManager.java:92

            try (ZipInputStream inStream = zipFile.getInputStream(packHeader)) {
                defBytes = IOUtils.readAll(inStream);
                pack = IconPack.fromBytes(defBytes);
            }

            // create a new directory to store the icon pack, based on the UUID and version
            File packDir = getIconPackDir(pack);
            if (!packDir.getCanonicalPath().startsWith(_iconsBaseDir.getCanonicalPath() + File.separator)) {
                throw new IOException("Attempted to write outside of the parent directory");
            }
            if (packDir.exists()) {
                throw new IconPackExistsException(pack);
            }
            IconPack existingPack = getIconPackByUUID(pack.getUUID());
            if (existingPack != null) {
                throw new IconPackExistsException(existingPack);
            }
            if (!packDir.exists() && !packDir.mkdirs()) {
                throw new IOException(String.format("Unable to create directories: %s", packDir.toString()));
            }

            // extract each of the defined icons to the icon pack directory
            for (IconPack.Icon icon : pack.getIcons()) {
                File destFile = new File(packDir, icon.getRelativeFilename());
                if (!destFile.getCanonicalPath().startsWith(packDir.getCanonicalPath() + File.separator)) {
                    throw new IOException("Attempted to write outside of the icon pack directory");
                }
                FileHeader iconHeader = zipFile.getFileHeader(icon.getRelativeFilename());
                if (iconHeader == null) {
                    throw new IOException(String.format("Unable to find %s relative to the root of the ZIP file", icon.getRelativeFilename()));
                }

                // create new directories for this file if needed
                File parent = destFile.getParentFile();
                if (parent != null && !parent.exists() && !parent.mkdirs()) {
                    throw new IOException(String.format("Unable to create directories: %s", packDir.toString()));
                }

View on GitHub (pinned to d6f4e5925a)