PHP Classes

Create file structure based on text string: Need to dynamically create a file system structure on the fly

Recommend this page to a friend!
  All requests RSS feed  >  Create file structure based on text s...  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

Create file structure based on text string

A request is featured when there is no good recommended package on the site when it is posted. Edit

Picture of Bryan Chasteen by Bryan Chasteen - 9 years ago (2015-01-26)

Need to dynamically create a file system structure on the fly

This request is clear and relevant.
This request is not clear or is not relevant.

+1

I need a class to quickly parse a string such as: /root/sub/sub-sub/sub-sub-sub and create folders, change their permissions and store one file in each folder as this process of folder creation is working.

I also need to delete or overwrite folders and files from previous runs that may have the same name.

  • 3 Clarification requests
  • 3. Picture of Alessandro Quintiliani by Alessandro Quintiliani - 8 years ago (2016-02-15) Reply

    Hello Brian

    I still have a class that might be suitable to your request.

    This class substantially makes a recursive copy from a source folder to a destination folder, recreating all those files and subdirs which do not exist (or overwriting otherwise), with each directory and file having the permission according to yuor settings.

    I am going to customize and test this class before posting, to make it more flexible and easy to implement.

    Hope it will suitable to you.

    Best regards

    Alessandro Quintiliani

    • 4. Picture of Manuel Lemos by Manuel Lemos - 8 years ago (2016-02-16) in reply to comment 3 by Alessandro Quintiliani Comment

      It seems he needs a class that copies files to a destination path but if the whole path does not exist, you need to create all the parent directories.

  • 2. Picture of Christian Vigh by Christian Vigh - 8 years ago (2016-02-15) Reply

    Hi Bryan,

    Ok, it is clear that the basic input parameter is a directory string.

    It is also clear about which processes are to be performed (create subdirs, overwrite folders and files, change permissions).

    However, there is one big information that is missing ; apart from the directory string, what is the input you have to process ? a list of files ? if yes,are you trying to search for some kind of syncing class ?

    On top of that, what are the rules that guide folder overwriting, permission change and so on ?

    Christian.

    • 1. Picture of Manuel Lemos by Manuel Lemos - 8 years ago (2016-02-15) Reply

      I have found some classes that can copy files to directories and create them if necessary, however it seems they only work if the parent destination directory already exists.

      Ask clarification

      1 Recommendation

      PHP Forms Class with HTML Generator and JavaScript Validation: HTML forms generation and validation.

      This recommendation solves the problem.
      This recommendation does not solve the problem.

      -1

      Picture of Peter by Peter Reputation 40 - 8 years ago (2016-02-16) Comment

      function mkdir_recursive($pathname) {

      if ($pathname==''){
          return false;
      }
      is_dir(dirname($pathname)) || mkdir_recursive(dirname($pathname));
      

      return is_dir($pathname) || @mkdir($pathname);
      

      }

      • 1 Comment
      • 1. Picture of Manuel Lemos by Manuel Lemos package author package author - 8 years ago (2016-02-16) Reply

        This is not a package recommendation.

        It is better to submit a package that implements that code.


      Recommend package
      : 
      :