Code Monkey home page Code Monkey logo

fscreator's Introduction

FSCreator

A simple library for declaring and creating files and directories.

Usage

To declare a file, create a new instance of FSFile class and give it a name and some content:

val file = FSFile("my_file", "myContent")

To declare a directory, create a new instance of FSDirectory class with a name and list of child entries -- they can be either files or directories as well:

val directory = FSDirectory(
    "my_directory", listOf(
        FSFile("nested_file", "in directory"),
        FSDirectory("nested_directory", listOf())
    )
)

Declared entries then can be created using FSCreator class:

val creator = FSCreator()
val destination = "/home/me/test"
creator.create(directory, destination)

Creator will check your hierarchy for errors and either report them to you in form of a list containing pairs of (errorneousEntry, errorDescription) or try to create it if no errors are found. However, something may go wrong during the creation process -- in this case, creator will also report entries that were not created along with the errors occurred.

Possible errors that prevent creation:

  • Entry name is empty or cannot be converted to filesystem path
  • destination is empty, or cannot be converted to path, or is not a directory in the filesystem
  • There are several entries with the same name in the same directory
  • For some entries there are files with the same name in the destination directory
  • Circular reference in the hierarchy (e.g. directory foo contains directory bar, which contains the same directory foo and hence itself)

Possible "runtime" errors:

  • There happened to exist a file with the same name as the entry name
  • Process does not have sufficient privileges to create files in the destination directory
  • Some unexpected IO error occurred

fscreator's People

Contributors

taifin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.