一.opendir与readdir函数 1.opendir是一个库函数,打开一个目录,并返回一个DIR指针给readdir函数 DIR *opendir(const char *name); 2.readdir是一个库函数,接收参数是DIR指针,返回一个struct dirent *结构体指针 st... ...
分类:
其他好文 时间:
2016-12-04 19:27:13
阅读次数:
162
//遍历文件夹下面所有的文件
functionmy_scandir($dir)
{
$files=array();
if($handle=opendir($dir)){
while(($files=readdir($handle))!==false){
if($files!="."&&$files!="."){
$files[$files]=my_scandir($dir."/".$files);
}else{
$files[]=$f..
分类:
Web程序 时间:
2016-11-24 00:05:37
阅读次数:
139
<?php function del_dir ($dir,$type=true){ $n=0; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ( $file = ...
分类:
Web程序 时间:
2016-11-16 02:38:06
阅读次数:
195
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<dirent.h>
#include<iostream>
usingnamespacestd;
voidprint(constchar*path){
DIR*dir=opendir(path);
if(NULL==d..
分类:
其他好文 时间:
2016-11-12 02:39:55
阅读次数:
247
之前面试的时候别人有这么一到面试题,说是用php来遍历整个目录,心里想着这有什么难得,可是真的写的时候却写不出来, 所以说年轻人写代码戒骄戒躁,所以今天把这个写了一下,代码如下: 这里介绍俩个函数一个是opendir()这个函数是打开一个目录并返回句柄,若目录为空则返回空, 另一个是readdir( ...
分类:
Web程序 时间:
2016-07-25 14:30:10
阅读次数:
221
1.file_exists()判断文件是否存在: 2.unlink删除一个文件 3.rewind 将指针复位到开始,ftell指针的所在位置,fseek指针定位在哪个位置 4.flock简单的锁定配合LOCK_EX和LOCK_UN使用 5.opendir与closedir的用法以及readdir s ...
分类:
Web程序 时间:
2016-07-22 18:47:05
阅读次数:
154
/**遍历一个文件夹下的所有文件和子文件夹 */function my_scandir($dir) { $files = array(); if(is_dir($dir)) { if($handle = opendir($dir)) { while(($file = readdir($handle) ...
分类:
其他好文 时间:
2016-06-30 19:44:26
阅读次数:
163
var readDir = require('readdir');var fs = require('fs'); function getImages(){ var imgarr = []; imgarr = readDir.readSync('images'); return imgarr;} f ...
分类:
其他好文 时间:
2016-06-14 19:22:54
阅读次数:
148
题目如下:实现linux下tree的单一功能[只打印目录个数和文件个数(不包含隐藏文件)]首选我们介绍几个相关的linux系统API函数名函数描述函数声明opendir打开一个目录,成功返回一个DIR*类型指针,失败返回NULLDIR*opendir(constchar*name)readdir读取打开的目录下的子成员,成..
分类:
系统相关 时间:
2016-06-08 10:52:51
阅读次数:
407
遍历访问文件夹: function read_folder_directory($dir) { $listDir = array(); if($handler = opendir($dir)) { while (($sub = readdir($handler)) !== FALSE) { if ( ...
分类:
Web程序 时间:
2016-05-18 00:18:57
阅读次数:
152