Retrieving File type
-
Hi all, Can we find programmatically what the FileType(whether it's PC or UNIX) of a text file? Is there any API available? Please suggest. Thanks, Mani
text files are identical on all operating systems..... UNIX , WINDOWS, LINUX :):-D:laugh: NG
-
Hi all, Can we find programmatically what the FileType(whether it's PC or UNIX) of a text file? Is there any API available? Please suggest. Thanks, Mani
Anonymous wrote: Can we find programmatically what the FileType(whether it's PC or UNIX) of a text file? AFAIK, txt file is same for every operating system!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
Hi all, Can we find programmatically what the FileType(whether it's PC or UNIX) of a text file? Is there any API available? Please suggest. Thanks, Mani
-
[Message Deleted]
-
Hi all, Can we find programmatically what the FileType(whether it's PC or UNIX) of a text file? Is there any API available? Please suggest. Thanks, Mani
As a rule, PC text files use carriage return / line feed pairs (\r\n, or 0x0D 0x0A) to delimit lines, while UNIX machines use line feed only (\n 0x0A). One approach would be to read the file as binary, and search for \r\n pairs. If you don't find them, try treating it as a UNIX file.
Software Zen:
delete this;
-
As a rule, PC text files use carriage return / line feed pairs (\r\n, or 0x0D 0x0A) to delimit lines, while UNIX machines use line feed only (\n 0x0A). One approach would be to read the file as binary, and search for \r\n pairs. If you don't find them, try treating it as a UNIX file.
Software Zen:
delete this;
I agree - this is the approach I have used in the past! Brute force and pig ignorance works every time. I've seen some text files which did line feed / carriage return instead of CR / LF - this confused the hell out of Microsoft Word (Word 97?)! I think they came from a PC which used OS/2 operating system.
-
As a rule, PC text files use carriage return / line feed pairs (\r\n, or 0x0D 0x0A) to delimit lines, while UNIX machines use line feed only (\n 0x0A). One approach would be to read the file as binary, and search for \r\n pairs. If you don't find them, try treating it as a UNIX file.
Software Zen:
delete this;
-
Ya, that's it what I was asking for. But just I want to know is there any other way to differentiate the two files. And, any API present to check carriage return or line feed (in VC++)? Thanks you all for your time.
Anonymous wrote: But just I want to know is there any other way to differentiate the two files. And, any API present to check carriage return or line feed (in VC++)? As far as I know, there isn't an API function for this. The code to do it should be pretty simple.
Software Zen:
delete this;