Git Product home page Git Product logo

fileoperations's Introduction

File Operations Preview

Documentation Status codecov Maintenance

GitHub license GitHub contributors

A library that helps developers to easily perform file-related operations. In iOS,

We write our files mainly into three directories Documents Directory, Temporary Directory, Cache Directory

Requirements

File Operations Version 0.0.15
iOS Version 10.0+
Xcode 10+
Swift 4.2

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'FileOperations'

Directory Types

DirectoryPath defines three directories which commonly used in our iOS application

  1. Documents Directory

  2. Temporary Directory

  3. Cache Directory

URL Methods

Get Document Directory URL

let documentDirectoryURL = FileOperations.getDocumentDirectoryURL()

Get Temporary Directory URL

let temporaryDirectoryURL =  FileOperations.getTemporaryDirectoryURL()

Get Cache Directory URL

let cacheDirectoryURL = FileOperations.getCacheDirectoryURL()

Directory Methods

Delete all contents of Directory Path

try? FileOperations.clearDirectory(path: .document)

Create directory in document/temp/cache directory with given file name. Method returns path of the directory created

let path = try? FileOperations.createDirectory(in: .document, direcotryName: "Image")

Create directory form given URL path. Method returns path of the directory created

let documentDirectoryURL = FileOperations.getDocumentDirectoryURL().appendingPathComponent("Images")

let path = try? FileOperations.createDirectory(with: documentDirectoryURL)

Remove directory from document/temp/cache directory with given file name

try? FileOperations.removeDirectory(by: .document, with: "Images")

Remove directory with provided URL

let documentDirectoryURL = FileOperations.getDocumentDirectoryURL().appendingPathComponent("test")

try? FileOperations.removeDirectory(with directoryURL:documentDirectoryURL)

Bundle Related Methods

Readt text file from bundle

 let fileContent = try? FileOperations.getText(form: Bundle.main, fileName: "sample")

Text File Operations

Create text file with file name and directory path

 let filePath =  try? FileOperations.createTextFile(in: .document, fileName: "About", content: "Sample Text")

Create text file form path

 let filePath =  try? FileOperations.createTextFile(with: path, content: "Sample Text")

Delete file with specified path

 let filePath =  try? FileOperations.createTextFile(with: path, content: "Sample Text")

Contributers


fileoperations's People

Contributors

binshadkb avatar rintoandrews90 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

binshadkb

fileoperations's Issues

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.