dnj/tmp-filesystem

Simple local interface to work with temporary files and directories

1.1.0 2022-01-11 11:39 UTC

This package is auto-updated.

Last update: 2024-11-17 13:45:01 UTC


README

Latest Version on Packagist Total Downloads Software License Testing status

Introduction

This is a simple implemenetation of DNJ\FileSystem for working with temporary disk based file system.

How To Use

First of all, you need to add this library to your project, so run:

composer require dnj/tmp-filesystem

Working with this filesystem is same as working with DNJ\local-filesystem
But you don't need to specify $path in the constructor of the Nodes. Because the file or directory is created in the temporary path of the operationg system.

For more information to how deal with this filesystem, you can read DNJ\local-filesystem README.md

Also, you don't need to delete temporary file and directories manually, because they have been automatically deleted when there is no pointer to them. (technically, when the __destruct method of object called.)

Create temporary file:

<?php
use dnj\Filesystem\Tmp\File;

$tmpFile = new File();
echo $tmppFile->getPath(); // prints the path of temporary file, in linux, it's may something like this: /tmp/qyiuqgi

Create temporary directory:

<?php
use dnj\Filesystem\Tmp\Directory;

$tmpDirectory = new Directory();
echo $tmpDirectory->getPath(); // prints the path of temporary directory, in linux, it's may something like this: /tmp/qyiuqgi

About

We'll try to maintain this project as simple as possible, but Pull Requests are welcomed!

License

The MIT License (MIT). Please see License File for more information.