SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist NokX's Avatar
    Join Date
    Feb 2003
    Location
    Knoxville, TN
    Posts
    529
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Overwriting a "Read Only" File

    i have a directory of files that are moved over via perl script. the files that are moved over are read only. which is fine, but after the main files are moved over i need to replace a few of them with alternate files. the problem is that since the files i want to replace are read only the copying fails.

    here's just the gist of what i'm doing:

    Code Perl:
    use File::Copy;
    use File::Path;
     
    copy('C:\\Users\\bgates\\Documents\\mypicture.jpg', 'K:\\Pictures\\mypicture.jpg') or die 'Copy failed: $!';

    if i want to move a new file or replace a non-read only file it works just fine.

    any ideas how i can do this over a read only file?

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Delete the read only file and add the new read only file?

  3. #3
    SitePoint Evangelist NokX's Avatar
    Join Date
    Feb 2003
    Location
    Knoxville, TN
    Posts
    529
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how can i delete the file via perl script? i'm a complete n00b to perl.

  4. #4
    SitePoint Evangelist NokX's Avatar
    Join Date
    Feb 2003
    Location
    Knoxville, TN
    Posts
    529
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nevermind... unlink does the trick. i didn't realize how similar perl is to php.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •