{
    "content": [
        {
            "type": "text",
            "text": "# File::Copy::Recursive (perldoc)\n\n## NAME\n\nFile::Copy::Recursive - Perl extension for recursively copying files and directories\n\n## SYNOPSIS\n\nuse File::Copy::Recursive qw(fcopy rcopy dircopy fmove rmove dirmove);\nfcopy($orig,$new[,$buf]) or die $!;\nrcopy($orig,$new[,$buf]) or die $!;\ndircopy($orig,$new[,$buf]) or die $!;\nfmove($orig,$new[,$buf]) or die $!;\nrmove($orig,$new[,$buf]) or die $!;\ndirmove($orig,$new[,$buf]) or die $!;\nrcopyglob(\"orig/stuff-*\", $trg [, $buf]) or die $!;\nrmoveglob(\"orig/stuff-*\", $trg [,$buf]) or die $!;\n\n## DESCRIPTION\n\nThis module copies and moves directories recursively (or single files, well... singley) to an\noptional depth and attempts to preserve each file or directory's mode.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **EXPORT** (8 subsections)\n- **SEE ALSO**\n- **TO DO**\n- **AUTHOR**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "File::Copy::Recursive",
        "section": "",
        "mode": "perldoc",
        "summary": "File::Copy::Recursive - Perl extension for recursively copying files and directories",
        "synopsis": "use File::Copy::Recursive qw(fcopy rcopy dircopy fmove rmove dirmove);\nfcopy($orig,$new[,$buf]) or die $!;\nrcopy($orig,$new[,$buf]) or die $!;\ndircopy($orig,$new[,$buf]) or die $!;\nfmove($orig,$new[,$buf]) or die $!;\nrmove($orig,$new[,$buf]) or die $!;\ndirmove($orig,$new[,$buf]) or die $!;\nrcopyglob(\"orig/stuff-*\", $trg [, $buf]) or die $!;\nrmoveglob(\"orig/stuff-*\", $trg [,$buf]) or die $!;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "EXPORT",
                "lines": 83,
                "subsections": [
                    {
                        "name": "Creating and Removing Paths",
                        "lines": 2
                    },
                    {
                        "name": "pathmk",
                        "lines": 67
                    },
                    {
                        "name": "Preserving Mode",
                        "lines": 3
                    },
                    {
                        "name": "Managing Depth",
                        "lines": 3
                    },
                    {
                        "name": "SymLinks",
                        "lines": 17
                    },
                    {
                        "name": "Removing existing target file or directory before copying.",
                        "lines": 22
                    },
                    {
                        "name": "stat",
                        "lines": 41
                    },
                    {
                        "name": "Allowing Copy Loops",
                        "lines": 16
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "TO DO",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "File::Copy::Recursive - Perl extension for recursively copying files and directories\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use File::Copy::Recursive qw(fcopy rcopy dircopy fmove rmove dirmove);\n\nfcopy($orig,$new[,$buf]) or die $!;\nrcopy($orig,$new[,$buf]) or die $!;\ndircopy($orig,$new[,$buf]) or die $!;\n\nfmove($orig,$new[,$buf]) or die $!;\nrmove($orig,$new[,$buf]) or die $!;\ndirmove($orig,$new[,$buf]) or die $!;\n\nrcopyglob(\"orig/stuff-*\", $trg [, $buf]) or die $!;\nrmoveglob(\"orig/stuff-*\", $trg [,$buf]) or die $!;\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This module copies and moves directories recursively (or single files, well... singley) to an\noptional depth and attempts to preserve each file or directory's mode.\n",
                "subsections": []
            },
            "EXPORT": {
                "content": "None by default. But you can export all the functions as in the example above and the path*\nfunctions if you wish.\n\nfcopy()\nThis function uses File::Copy's copy() function to copy a file but not a directory. Any\ndirectories are recursively created if need be. One difference to File::Copy::copy() is that\nfcopy attempts to preserve the mode (see Preserving Mode below) The optional $buf in the\nsynopsis is the same as File::Copy::copy()'s 3rd argument. This function returns the same as\nFile::Copy::copy() in scalar context and 1,0,0 in list context to accomodate rcopy()'s list\ncontext on regular files. (See below for more info)\n\ndircopy()\nThis function recursively traverses the $orig directory's structure and recursively copies it to\nthe $new directory. $new is created if necessary (multiple non existent directories is ok (i.e.\nfoo/bar/baz). The script logically and portably creates all of them if necessary). It attempts\nto preserve the mode (see Preserving Mode below) and by default it copies all the way down into\nthe directory (see Managing Depth, below). If a directory is not specified it croaks just like\nfcopy croaks if its not a file that is specified.\n\nThis function returns true or false: for true in scalar context it returns the number of files\nand directories copied, whereas in list context it returns the number of files and directories,\nnumber of directories only, depth level traversed.\n\nmy $numoffilesanddirs = dircopy($orig,$new);\nmy($numoffilesanddirs,$numofdirs,$depthtraversed) = dircopy($orig,$new);\n\nNormally it stops and returns if a copy fails. To continue on regardless, set\n$File::Copy::Recursive::SkipFlop to true.\n\nlocal $File::Copy::Recursive::SkipFlop = 1;\n\nThat way it will copy everythging it can in a directory and won't stop because of permissions,\netc...\n\nrcopy()\nThis function will allow you to specify a file *or* a directory. It calls fcopy() if you passed\nfile and dircopy() if you passed a directory. If you call rcopy() (or fcopy() for that matter)\non a file in list context, the values will be 1,0,0 since no directories and no depth are used.\nThis is important because if it's a directory in list context and there is only the initial\ndirectory the return value is 1,1,1.\n\nrcopyglob()\nThis function lets you specify a pattern suitable for perl's File::Glob::bsdglob() as the first\nargument. Subsequently each path returned by perl's File::Glob::bsdglob() gets rcopy()ied.\n\nIt returns and array whose items are array refs that contain the return value of each rcopy()\ncall.\n\nIt forces behavior as if $File::Copy::Recursive::CPRFComp is true.\n\nfmove()\nCopies the file then removes the original. You can manage the path the original file is in\naccording to $RemvBase.\n\ndirmove()\nUses dircopy() to copy the directory then removes the original. You can manage the path the\noriginal directory is in according to $RemvBase.\n\nrmove()\nLike rcopy() but calls fmove() or dirmove() instead.\n\nrmoveglob()\nLike rcopyglob() but calls rmove() instead of rcopy()\n\n$RemvBase\nDefault is false. When set to true the *move() functions will not only attempt to remove the\noriginal file or directory but will remove the given path it is in.\n\nSo if you:\n\nrmove('foo/bar/baz', '/etc/');\n# \"baz\" is removed from foo/bar after it is successfully copied to /etc/\n\nlocal $File::Copy::Recursive::Remvbase = 1;\nrmove('foo/bar/baz','/etc/');\n# if baz is successfully copied to /etc/ :\n# first \"baz\" is removed from foo/bar\n# then \"foo/bar is removed via pathrm()\n\n$ForcePth\nDefault is false. When set to true it calls pathempty() before any directories are removed to\nempty the directory so it can be rmdir()'ed when $RemvBase is in effect.\n",
                "subsections": [
                    {
                        "name": "Creating and Removing Paths",
                        "content": "$NoFtlPth\nDefault is false. If set to true rmdir(), mkdir(), and pathempty() calls in pathrm() and"
                    },
                    {
                        "name": "pathmk",
                        "content": "If its set to true they just silently go about their business regardless. This isn't a good idea\nbut it's there if you want it.\n\n$DirPerms\nMode to pass to any mkdir() calls. Defaults to 0777 as per umask()'s POD. Explicitly having this\nallows older perls to be able to use FCR and might add a bit of flexibility for you.\n\nAny value you set it to should be suitable for oct().\n\nPath functions\nThese functions exist solely because they were necessary for the move and copy functions to have\nthe features they do and not because they are of themselves the purpose of this module. That\nbeing said, here is how they work so you can understand how the copy and move functions work and\nuse them by themselves if you wish.\n\npathrm()\nRemoves a given path recursively. It removes the *entire* path so be careful!!!\n\nReturns 2 if the given path is not a directory.\n\nFile::Copy::Recursive::pathrm('foo/bar/baz') or die $!;\n# foo no longer exists\n\nSame as:\n\nrmdir 'foo/bar/baz' or die $!;\nrmdir 'foo/bar' or die $!;\nrmdir 'foo' or die $!;\n\nAn optional second argument makes it call pathempty() before any rmdir()'s when set to true.\n\nFile::Copy::Recursive::pathrm('foo/bar/baz', 1) or die $!;\n# foo no longer exists\n\nSame as:PFSCheck\n\nFile::Copy::Recursive::pathempty('foo/bar/baz') or die $!;\nrmdir 'foo/bar/baz' or die $!;\nFile::Copy::Recursive::pathempty('foo/bar/') or die $!;\nrmdir 'foo/bar' or die $!;\nFile::Copy::Recursive::pathempty('foo/') or die $!;\nrmdir 'foo' or die $!;\n\nAn optional third argument acts like $File::Copy::Recursive::NoFtlPth, again probably not a good\nidea.\n\npathempty()\nRecursively removes the given directory's contents so it is empty. Returns 2 if the given\nargument is not a directory, 1 on successfully emptying the directory.\n\nFile::Copy::Recursive::pathempty($pth) or die $!;\n# $pth is now an empty directory\n\npathmk()\nCreates a given path recursively. Creates foo/bar/baz even if foo does not exist.\n\nFile::Copy::Recursive::pathmk('foo/bar/baz') or die $!;\n\nAn optional second argument if true acts just like $File::Copy::Recursive::NoFtlPth, which means\nyou'd never get your die() if something went wrong. Again, probably a *bad* idea.\n\npathrmdir()\nSame as rmdir() but it calls pathempty() first to recursively empty it first since rmdir can not\nremove a directory with contents. Just removes the top directory the path given instead of the\nentire path like pathrm(). Returns 2 if the given argument does not exist (i.e. it's already\ngone). Returns false if it exists but is not a directory.\n"
                    },
                    {
                        "name": "Preserving Mode",
                        "content": "By default a quiet attempt is made to change the new file or directory to the mode of the old\none. To turn this behavior off set $File::Copy::Recursive::KeepMode to false;\n"
                    },
                    {
                        "name": "Managing Depth",
                        "content": "You can set the maximum depth a directory structure is recursed by setting:\n$File::Copy::Recursive::MaxDepth to a whole number greater than 0.\n"
                    },
                    {
                        "name": "SymLinks",
                        "content": "If your system supports symlinks then symlinks will be copied as symlinks instead of as the\ntarget file. Perl's symlink() is used instead of File::Copy's copy(). You can customize this\nbehavior by setting $File::Copy::Recursive::CopyLink to a true or false value. It is already set\nto true or false depending on your system's support of symlinks so you can check it with an if\nstatement to see how it will behave:\n\nif($File::Copy::Recursive::CopyLink) {\nprint \"Symlinks will be preserved\\n\";\n} else {\nprint \"Symlinks will not be preserved because your system does not support it\\n\";\n}\n\nIf symlinks are being copied you can set $File::Copy::Recursive::BdTrgWrn to true to make it\ncarp when it copies a link whose target does not exist. It's false by default.\n\nlocal $File::Copy::Recursive::BdTrgWrn  = 1;\n"
                    },
                    {
                        "name": "Removing existing target file or directory before copying.",
                        "content": "This can be done by setting $File::Copy::Recursive::RMTrgFil or $File::Copy::Recursive::RMTrgDir\nfor file or directory behavior respectively.\n\n0 = off (This is the default)\n\n1 = carp() $! if removal fails\n\n2 = return if removal fails\n\nlocal $File::Copy::Recursive::RMTrgFil = 1;\nfcopy($orig, $target) or die $!;\n# if it fails it does warn() and keeps going\n\nlocal $File::Copy::Recursive::RMTrgDir = 2;\ndircopy($orig, $target) or die $!;\n# if it fails it does your \"or die\"\n\nThis should be unnecessary most of the time but it's there if you need it :)\n\nTurning off stat() check\nBy default the files or directories are checked to see if they are the same (i.e. linked, or two\npaths (absolute/relative or different relative paths) to the same file) by comparing the file's"
                    },
                    {
                        "name": "stat",
                        "content": "if you must for some weird reason just set $File::Copy::Recursive::PFSCheck to a false value.\n(\"PFS\" stands for \"Physical File System\")\n\nEmulating cp -rf dir1/ dir2/\nBy default dircopy($dir1,$dir2) will put $dir1's contents right into $dir2 whether $dir2 exists\nor not.\n\nYou can make dircopy() emulate cp -rf by setting $File::Copy::Recursive::CPRFComp to true.\n\nNOTE: This only emulates -f in the sense that it does not prompt. It does not remove the target\nfile or directory if it exists. If you need to do that then use the variables $RMTrgFil and\n$RMTrgDir described in \"Removing existing target file or directory before copying\" above.\n\nThat means that if $dir2 exists it puts the contents into $dir2/$dir1 instead of $dir2 just like\ncp -rf. If $dir2 does not exist then the contents go into $dir2 like normal (also like cp -rf).\n\nSo assuming 'foo/file':\n\ndircopy('foo', 'bar') or die $!;\n# if bar does not exist the result is bar/file\n# if bar does exist the result is bar/file\n\n$File::Copy::Recursive::CPRFComp = 1;\ndircopy('foo', 'bar') or die $!;\n# if bar does not exist the result is bar/file\n# if bar does exist the result is bar/foo/file\n\nYou can also specify a star for cp -rf glob type behavior:\n\ndircopy('foo/*', 'bar') or die $!;\n# if bar does not exist the result is bar/file\n# if bar does exist the result is bar/file\n\n$File::Copy::Recursive::CPRFComp = 1;\ndircopy('foo/*', 'bar') or die $!;\n# if bar does not exist the result is bar/file\n# if bar does exist the result is bar/file\n\nNOTE: The '*' is only like cp -rf foo/* and *DOES NOT EXPAND PARTIAL DIRECTORY NAMES LIKE YOUR\nSHELL DOES* (i.e. not like cp -rf fo* to copy foo/*).\n"
                    },
                    {
                        "name": "Allowing Copy Loops",
                        "content": "If you want to allow:\n\ncp -rf . foo/\n\ntype behavior set $File::Copy::Recursive::CopyLoop to true.\n\nThis is false by default so that a check is done to see if the source directory will contain the\ntarget directory and croaks to avoid this problem.\n\nIf you ever find a situation where $CopyLoop = 1 is desirable let me know. (i.e. it's a bad bad\nidea but is there if you want it)\n\n(Note: On Windows this was necessary since it uses stat() to determine sameness and stat() is\nessentially useless for this on Windows. The test is now simply skipped on Windows but I'd\nrather have an actual reliable check if anyone in Microsoft land would care to share)\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "File::Copy File::Spec\n",
                "subsections": []
            },
            "TO DO": {
                "content": "I am currently working on and reviewing some other modules to use in the new interface so we can\nlose the horrid globals as well as some other undesirable traits and also more easily make\navailable some long standing requests.\n\nTests will be easier to do with the new interface and hence the testing focus will shift to the\nnew interface and aim to be comprehensive.\n\nThe old interface will work, it just won't be brought in until it is used, so it will add no\noverhead for users of the new interface.\n\nI'll add this after the latest version has been out for a while with no new features or issues\nfound :)\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Daniel Muey, <http://drmuey.com/cpancontact.pl>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "Copyright 2004 by Daniel Muey\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
                "subsections": []
            }
        }
    }
}