473,327 Members | 1,524 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Copy file/dir DOESN'T save permissions

6
Hi,

Suspiciously, perl does not save file's permission when coping it.

In order to implement the copy , I use : use File::Copy; and File::Copy::Recursive.

The BIG problem is that the file permissions wont be saved after coping it to another place.

I found a clumsy way to keep the permission in copy();
but I dont have any idea how to achive it in discopy() as well.

Tnx for your patient ...
Waiting for your reply

Ofzer
Jul 18 '07 #1
1 5831
miller
1,089 Expert 1GB
I've never come by that issue before, but then again, I've always simply gone with default permissions. At the very least you can simply create a subroutine to mirror the permissions after copying as this is not a time intensive operation like the actual copying itself is.

Expand|Select|Wrap|Line Numbers
  1. use Carp qw(croak);
  2.  
  3. sub mirrorPermissions {
  4.     my $oldfile = shift;
  5.     my $newfile = shift;
  6.     croak("Source and destination files must exist") unless -e $oldfile && -e $newfile;
  7.  
  8.     my $mode = (stat($oldfile))[2] & 0777;
  9.     return chmod $mode, $newfile;
  10. }
  11.  
perldoc chmod
perldoc stat

- Miller
Jul 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Ivan Demkovitch | last post by:
Hi! I would like to know if I can save File on Server using server-side code? For example, I like to create thumbnail images and populate specific directory. Do I need specific permissions...
6
by: Greg Collins [MVP] | last post by:
For background, please refer to my original thread: http://groups.google.com/groups?selm=efe5w7tYEHA.3112%40tk2msftngp13.phx.gbl I've thought of a potential way around the issue, but I'm new to...
6
by: Pat Carden | last post by:
Hi, We need to allow webusers to upload a file on our website (on Server3, all servers run Server 2003, remotely hosted) and eventually save it on our SBS Server (Server2) which is not exposed...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
1
by: Knepper, Michelle | last post by:
Hi out there, I'm a first-time user of the "Copy ... From..." command, and I'm trying to load a table from a text flat file. http://www.postgresql.org/docs/7.4/static/sql-copy.html I don't...
8
by: Paw | last post by:
Greetings. I use asp. what I need is is when a visitor comes to the site, I need it to check the host name. if "www.hometowndigest.com" is the host, then check a folder named "something" and if...
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
3
by: Steven Voordijk | last post by:
I'm writing code to copy, manipulate and save an image file. The code written is based on this article by Microsoft; http://support.microsoft.com/?id=814675 Unfortunately, the...
0
by: sivaramsekar | last post by:
Hi, I have a requirement to copy files (images) from a different server to our web server which has IIS 6.0 and asp.net 3.5. When i try it in my local dev machine i am able to copy and save...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.