LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-26-2009, 10:18 PM   #1
Metropolis
LQ Newbie
 
Registered: Jun 2009
Posts: 21

Rep: Reputation: 15
File format messed up when copying


Hello everyone,

Whenever I copy programming files from windows XP to Fedora 11, leading spaces are being added to a number of the lines in the files. I am using mercurial for revision control and it is coming back and telling me that all the files in the repositories have been modified because of this.

Is there a way to fix this?

Thanks,

Metropolis
 
Old 07-27-2009, 12:40 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,251

Rep: Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026
What tools are you using to create and copy the files, also to read on Linux?
It sounds like a tab char is converting to an equiv num of spaces.
Have you also allowed for the different line ending conventions?
In MS it's <CR><LF>, in *nix it's just <LF>, hence the dos2unix and unix2dos tools.
 
Old 07-27-2009, 08:30 AM   #3
Metropolis
LQ Newbie
 
Registered: Jun 2009
Posts: 21

Original Poster
Rep: Reputation: 15
Yeah I think you are right about the tabbing changing to spaces. I use netbeans for my IDE, and I just copied them from one hard drive to another. The weird thing though is that the formatting is getting messed up before I ever open the file. Right once I copy the file to Fedora, mercurial see's a problem.

Metropolis
 
Old 07-27-2009, 08:37 AM   #4
nowonmai
Member
 
Registered: Jun 2003
Posts: 481

Rep: Reputation: 47
How are you doing the copy? I don't think it's cp, is it?
 
Old 07-27-2009, 08:39 AM   #5
Metropolis
LQ Newbie
 
Registered: Jun 2009
Posts: 21

Original Poster
Rep: Reputation: 15
No im just dragging from one hard drive to the other
 
Old 07-27-2009, 09:43 AM   #6
Metropolis
LQ Newbie
 
Registered: Jun 2009
Posts: 21

Original Poster
Rep: Reputation: 15
Ok I think I fixed the formatting issue. In netbeans I made the tabbed space be the same as the indent space for both windows and linux. I believe that linux reads the tabbed spaces differently.

However, mercurial is still coming back and telling me that every file has been modified, but it does not show that there are any changes in any of the files. It seems as if the binary code of the file is being changed, but its not affecting the format. Why would the binary code of the file change across platforms?

Metropolis
 
Old 07-27-2009, 09:49 AM   #7
nowonmai
Member
 
Registered: Jun 2003
Posts: 481

Rep: Reputation: 47
Does mercurial examine any of the file meta-data? Last accessed/modified time? That's the only thing that will|should change.
 
Old 07-27-2009, 10:02 AM   #8
Metropolis
LQ Newbie
 
Registered: Jun 2009
Posts: 21

Original Poster
Rep: Reputation: 15
Thats a very good question....And i would not be surprised if your right about that being the problem......Only thing is, how to fix that....

Metropolis
 
Old 07-27-2009, 01:20 PM   #9
Metropolis
LQ Newbie
 
Registered: Jun 2009
Posts: 21

Original Poster
Rep: Reputation: 15
Heres another thing. If I copy the files from Windows to Linux, I get the modified problem. If I copy them from Linux to Windows there is no problems.

Metropolis
 
Old 07-30-2009, 10:05 AM   #10
Metropolis
LQ Newbie
 
Registered: Jun 2009
Posts: 21

Original Poster
Rep: Reputation: 15
Just to let anyone know who is having this problem. I found that if you FTP your repo's from the windows machine in binary mode to a server, and then FTP them to your linux machine, it fixes this issue. Thanks to everyone that tried to help.

Metropolis
 
Old 07-30-2009, 10:13 AM   #11
nowonmai
Member
 
Registered: Jun 2003
Posts: 481

Rep: Reputation: 47
^
Wow... that's some workaround
 
Old 07-30-2009, 06:11 PM   #12
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Quote:
Originally Posted by Metropolis View Post
No im just dragging from one hard drive to the other
Samba right?
 
Old 07-31-2009, 08:43 AM   #13
Metropolis
LQ Newbie
 
Registered: Jun 2009
Posts: 21

Original Poster
Rep: Reputation: 15
Hey, its works, its not that hard to do and im happy


Metropolis
 
Old 07-31-2009, 11:55 AM   #14
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Quote:
Whenever I copy programming files from windows XP to Fedora 11, leading spaces are being added to a number of the lines in the files.
"Programming files" are presumably "plain text" files. You'd expect them to be just that but it's a little more complicated, thanks to microsoft.

Some background:

Windows and *nix handle text files differently (a bit the same as windows chose "\" to be the separator for file paths, when the established convention was already "/").

A windows End Of Line (EOL) is CRLF
A *nix EOL is just LF

So "plain text" files from (windows) notepad have an extra character when imported to *nix.

These problems can be solved with the utilities dos2unix filename and unix2dos filename which convert the EOL character(s) appropriately.

Here endeth the history lesson.
 
Old 07-31-2009, 11:21 PM   #15
Metropolis
LQ Newbie
 
Registered: Jun 2009
Posts: 21

Original Poster
Rep: Reputation: 15
I actually think that FTPing the files would be easier then going through all of my folders and trying to fix all the files. I have alot of files to keep up with, so it just seems easier to FTP the whole folder and be done with it.

Also, as I said before. I fixed the spacing issues with Netbeans. The problem Im still having is that Mercurial is saying all of my files have been modified, but they dont show any changes, which I believe nowonmai may be right about the last modified data changing. I just have no idea how I would get Mercurial to not pay attention to this, or why it would make any difference when I copy it from Windows to Linux.

Metropolis

Last edited by Metropolis; 07-31-2009 at 11:25 PM.
 
  


Reply

Tags
copying, file, format


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
not in executable format: File format not recognized ypy13 Linux - Newbie 9 07-09-2008 11:33 PM
gdb "not in executable format: File format not recognized" tcma Programming 9 07-18-2007 06:02 AM
Strange Problem: Install freezes on format of HDB7 or copying files to HDB7 cowboy45 Mandriva 0 08-18-2004 11:26 PM
Trying to format a floppy - I think I messed something up mary Linux - General 5 11-05-2003 04:04 PM
Question on File System and File Copying hey_joe Linux - Newbie 2 11-05-2003 10:30 AM


All times are GMT -5. The time now is 11:34 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration