Subversion Repositories Applications.papyrus

Rev

Rev 71 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
70 jpm 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: FIC_manipulation.fonct.php,v 1.1 2004-10-18 10:09:12 jpm Exp $
23
/**
24
* Bibliothèque de fonctions permettant de manipuler des fichier ou des dossiers.
25
*
26
* Contient des fonctions permettant de manipuler des fichier ou des dossiers.
27
*
28
*@package Fichier
29
//Auteur original :
30
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
31
//Autres auteurs :
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.1 $ $Date: 2004-10-18 10:09:12 $
35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                           LISTE de FONCTIONS                                         |
40
// +------------------------------------------------------------------------------------------------------+
41
 
42
/**
43
* Fonction supprimerDossier() - Supprime un fichier ou un dossier et tout son contenu.
44
*
45
* Fonction récursive supprimant tout le contenu d'un dossier.
46
* Auteur d'origine : Aidan Lister (http://aidan.dotgeek.org/lib/?file=function.rmdirr.php)
47
* Traduction française et ajout gestion séparateur : Jean-Pascal Milcent
48
*
49
* @author      Aidan Lister <aidan@php.net>
50
* @author      Jean-Pascal Milcent <jpm@tela-botanica.org>
51
* @version     1.0.0
52
* @param       string   $dirname    The directory to delete
53
* @return      bool     Returns true on success, false on failure
54
*/
55
function supprimerDossier($dossier_nom, $separateur)
56
{
57
    // Simple suppression d'un fichier
58
    if (is_file($dossier_nom)) {
59
        return unlink($dossier_nom);
60
    }
61
 
62
    // Analyse du dossier
63
    $dossier = dir($dossier_nom);
64
    while (false !== $entree = $dossier->read()) {
65
        // Nous sautons les pointeurs
66
        if ($entree == '.' || $entree == '..') {
67
            continue;
68
        }
69
 
70
        // Suppression du dossier ou appel récursif de la fonction
71
        if (is_dir($dossier_nom.$separateur.$entree)) {
72
            supprimerDossier($dossier_nom.$separateur.$entree);
73
        } else {
74
            unlink($dossier_nom.$separateur.$entree);
75
        }
76
    }
77
 
78
    // Nettoyage
79
    $dossier->close();
80
    return rmdir($dossier_nom);
81
}
82
 
83
/* +--Fin du code ----------------------------------------------------------------------------------------+
84
*
85
* $Log: not supported by cvs2svn $
86
*
87
* +-- Fin du code ----------------------------------------------------------------------------------------+
88
*/
89
?>