Link to home
Start Free TrialLog in
Avatar of ashish_bansal
ashish_bansal

asked on

reading unix files on windows.

how can I open the unix files on windows platform? If I want to write an application for this, can is it possible programming in Java and what all basic file system knowledge is required?
Avatar of mliberi
mliberi

A unix file is simply a string og bytes. Windows concept of file is exactly the same. So, open unix files just as thay was windows files.

A little difference is about TEXT files. Unix uses <LF> (ascii 10) as line terminator, Windows uses <CR><LF> (ascii 13 10).
Hi ashish,

You are not very clear.
Do you want to write a utility to convery a file of Unix to windows or
want to open a file lying on Unix machine on NT?


Please give more information on your requirement.
you can write a prog in c\c++ even in unix that open's a file it will work in windows platform as well

if in c++ or<use g++ compiler in unix>
you can use the class ifstream that in
fstream.h

#include <fstream.h>

int main(){
   ifstream f("path\filename");
   ifstream fp;
   fp.open("path\filename",ios::binary);
   //then you can use the func to read
   //or the operator >>

return 0;
}
Pls give more info. Your question is not very clear.
ashish, there is no such thing as a "unix file".

There are text files that use a "Unix line terminator convention".  I.e., LF is used as an end-of-line marker instead of a CR+LF pair that is used in DOS, Windows, OS/2 etc.

There are also certain file systems used on Unix platform.

Which one interests you.

Incidently, you seem to have abandoned Q.10308075 on a similar subject.  Please revisit it.
Avatar of ashish_bansal

ASKER

What I actually meant by opening a unix file in windows is that if there is a floppy or CD which is unix or linux formatted then it cannot be read on windows platform and vice-versa. How can we thus read the contents of floppy or CD formatted on windows on linux or unix.
mostly CD will be ISO9660 format with some extension, thus should be available on any OS which supports ISO9660 such as windows, linux and most UNIXs.  If a CD or a floppy is in a raw format of
file system unknown to the OS, then, you are right, it could be hard to read.

Windows lack support for other file systems. Linux doesnot. Linux support DOS,FAT16, FAT32(?), NTFS. If you have dos floppy or CDROM (iso9660 with Juliet extension, most likely),

on your Linux box, to view your windows CD/floppy, you have to superuser to do the following unless you've set special permission for some ordinary user.
1) mount -t vfat /dev/fd0 /mnt/floppy
2) mount -t iso9660 /dev/cdrom /mnt/cdrom

then you can access files at /mnt/floppy or /mnt/cdrom.
1) cd /mnt/floppy && ls -aF --color
2) cd /mnt/cdrom && ls -af --color

Some window manager will have GUI interface allow to click click thing, you can do that too. for instance, with RH6+, you can click on the cdrom icon on your desktop, then choose 'open' or 'mount'.
The problem you might have is when trying to 'double click' the file to view it in windows.

Don't.

Windoze only looks at the three letter extension of a file to see how to open it, eg (.txt -> Notepad, .xls -> Excel).  Unix system don't have this problem because they either look at the file's cookie or are entered directly (eg, `cat file`).

Try creating a shortcut to c:\windows\notepad on your desktop and drag the files over that - or use the "open with" and specify always open in notepad.  (Shift+Right Click the file).
ASKER CERTIFIED SOLUTION
Avatar of onalenna
onalenna

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want to write your own program that does that, you can use a socket
connection between the unix box and the windows box. You will have to write a little program on the unix machine that reads the files and send the content on the socket, and make it the way u want.

The windows app will get the data from the socket...

WIN     ----- tcp/ip ---- Unix

Your unix process could be there waiting  for the windows app to connect (or, if you need multiple file transfer at the same time, you could have a pool of unix  apps waiting for the windows apps to connect.

The unix app could also be called by RPC  from the windows box.