Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Retrieving File type

Retrieving File type

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestion
9 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    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

    N T E G 4 Replies Last reply
    0
    • A Anonymous

      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

      N Offline
      N Offline
      Neagoe Gabriel
      wrote on last edited by
      #2

      text files are identical on all operating systems..... UNIX , WINDOWS, LINUX :):-D:laugh: NG

      1 Reply Last reply
      0
      • A Anonymous

        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

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • A Anonymous

          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

          E Offline
          E Offline
          Eytukan
          wrote on last edited by
          #4

          .txt is .txt V

          M 1 Reply Last reply
          0
          • E Eytukan

            .txt is .txt V

            M Offline
            M Offline
            Monisankar
            wrote on last edited by
            #5

            [Message Deleted]

            1 Reply Last reply
            0
            • A Anonymous

              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

              G Offline
              G Offline
              Gary R Wheeler
              wrote on last edited by
              #6

              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;

              N A 2 Replies Last reply
              0
              • G Gary R Wheeler

                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;

                N Offline
                N Offline
                normanS
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • G Gary R Wheeler

                  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;

                  A Offline
                  A Offline
                  Anonymous
                  wrote on last edited by
                  #8

                  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.

                  G 1 Reply Last reply
                  0
                  • A Anonymous

                    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.

                    G Offline
                    G Offline
                    Gary R Wheeler
                    wrote on last edited by
                    #9

                    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;

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups