dnj/tmp-filesystem

用于处理临时文件和目录的简单本地接口

1.1.0 2022-01-11 11:39 UTC

This package is auto-updated.

Last update: 2024-09-17 13:22:04 UTC


README

Latest Version on Packagist Total Downloads Software License Testing status

简介

这是一个用于操作基于磁盘的临时文件系统的简单实现 DNJ\FileSystem

如何使用

首先,您需要将此库添加到您的项目中,因此运行

composer require dnj/tmp-filesystem

使用此文件系统的方式与使用 DNJ\local-filesystem 相同
但是,您不需要在 Nodes 构造函数中指定 $path,因为文件或目录将在操作系统的临时路径中创建。

有关如何处理此文件系统的更多信息,您可以阅读 DNJ\local-filesystem README.md

此外,您不需要手动删除临时文件和目录,因为当没有指向它们的指针时,它们将被自动删除。(技术上,当调用对象的 __destruct 方法时。)

创建临时文件

<?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

创建临时目录

<?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

关于

我们将尽量使此项目尽可能简单,但欢迎 Pull Requests!

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件