Given a file pointer is there any way to get the fill path to thefile

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • parag_paul@hotmail.com

    Given a file pointer is there any way to get the fill path to thefile

    I tried unistd.h
    but nothing much
  • Ian Collins

    #2
    Re: Given a file pointer is there any way to get the fill path tothe file

    parag_paul@hotm ail.com wrote:
    I tried unistd.h
    but nothing much
    Tried what? Ah, I see you hid your question in the subject line.

    This topic has been done to death here several times, check the archives.

    --
    Ian Collins.

    Comment

    • Eric Sosman

      #3
      Re: Given a file pointer is there any way to get the fill path tothe file

      parag_paul@hotm ail.com wrote:
      I tried unistd.h
      but nothing much
      (Please put your question in the body of your message, and use
      the Subject line as a "title" or "motto" for the discussion. Don't
      rely on Subject to carry the whole load.)

      This is Question 19.15 in the comp.lang.c Frequently Asked
      Questions (FAQ) list, <http://www.c-faq.com/>, and you're not
      going to like the answer.

      --
      Eric.Sosman@sun .com

      Comment

      • Keith Thompson

        #4
        Re: Given a file pointer is there any way to get the fill path to the file

        "parag_paul@hot mail.com" <parag_paul@hot mail.comwrites:
        I tried unistd.h
        but nothing much
        Please put the question:

        Given a file pointer is there any way to get the fill path to the
        file

        in the body of your message.

        There is no way in standard C to do this, unless you remember the file
        name when you open it. The reference to unistd.h implies that you're
        using a Unix-like system; I don't believe there's any direct way to do
        this under Unix either, but if there is you'll get better answers in
        comp.unix.progr ammer (check their FAQ(s) first).

        --
        Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
        Nokia
        "We must do something. This is something. Therefore, we must do this."
        -- Antony Jay and Jonathan Lynn, "Yes Minister"

        Comment

        • vippstar@gmail.com

          #5
          Re: Given a file pointer is there any way to get the fill path to thefile

          On Oct 3, 11:29 pm, Keith Thompson <ks...@mib.orgw rote:
          <snip>
          The reference to unistd.h implies that you're
          using a Unix-like system; I don't believe there's any direct way to do
          this under Unix either, but if there is you'll get better answers in
          comp.unix.progr ammer (check their FAQ(s) first).
          I've asked before, they don't have one :-(
          It'd be helpful.

          Comment

          • lawrence.jones@siemens.com

            #6
            Re: Given a file pointer is there any way to get the fill path to the ?file

            parag_paul@hotm ail.com <parag_paul@hot mail.comwrote:
            I tried unistd.h
            but nothing much
            It would be helpful if you actually stated your question (how to get a
            file name from a file pointer) in the text rather than just in the
            subject.

            On many systems, there is no unique mapping between file names and
            files; there can be zero, one, or many names for a file. There is no
            function either in standard C or in Posix to do that.
            --
            Larry Jones

            Mom would be a lot more fun if she was a little more gullible. -- Calvin

            Comment

            • Keith Thompson

              #7
              Re: Given a file pointer is there any way to get the fill path to the file

              vippstar@gmail. com writes:
              On Oct 3, 11:29 pm, Keith Thompson <ks...@mib.orgw rote:
              <snip>
              >The reference to unistd.h implies that you're
              >using a Unix-like system; I don't believe there's any direct way to do
              >this under Unix either, but if there is you'll get better answers in
              >comp.unix.prog rammer (check their FAQ(s) first).
              >
              I've asked before, they don't have one :-(
              It'd be helpful.
              A Unix FAQ is posted regularly to comp.unix.quest ions and
              comp.unix.shell . See, for example,
              <http://www.faqs.org/faqs/unix-faq/faq/>. Question 4.3 is "How do I
              find the name of an open file?". (The answer was written 15 years
              ago, but I don't think anything has changed.)

              --
              Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
              Nokia
              "We must do something. This is something. Therefore, we must do this."
              -- Antony Jay and Jonathan Lynn, "Yes Minister"

              Comment

              • parag_paul@hotmail.com

                #8
                Re: Given a file pointer is there any way to get the fill path to thefile

                On Oct 4, 2:26 am, vipps...@gmail. com wrote:
                On Oct 3, 11:29 pm, Keith Thompson <ks...@mib.orgw rote:
                <snip>
                >
                The reference to unistd.h implies that you're
                using a Unix-like system; I don't believe there's any direct way to do
                this under Unix either, but if there is you'll get better answers in
                comp.unix.progr ammer (check their FAQ(s) first).
                >
                I've asked before, they don't have one :-(
                It'd be helpful.
                A small question ,
                where can I find the archives and is there a direct search to the same

                Comment

                • Keith Thompson

                  #9
                  Re: Given a file pointer is there any way to get the fill path to the file

                  "parag_paul@hot mail.com" <parag_paul@hot mail.comwrites:
                  On Oct 4, 2:26 am, vipps...@gmail. com wrote:
                  >On Oct 3, 11:29 pm, Keith Thompson <ks...@mib.orgw rote:
                  ><snip>
                  >>
                  The reference to unistd.h implies that you're
                  using a Unix-like system; I don't believe there's any direct way to do
                  this under Unix either, but if there is you'll get better answers in
                  comp.unix.progr ammer (check their FAQ(s) first).
                  >>
                  >I've asked before, they don't have one :-(
                  >It'd be helpful.
                  >
                  A small question ,
                  where can I find the archives and is there a direct search to the same
                  Um, which archives? groups.google.c om archives most Usenet posts.
                  www.faqs.org archives frequently asked questions list, though not in a
                  particularly reader-friendly format. I found the Unix FAQ by a simple
                  Google search for "Unix FAQ".

                  --
                  Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                  Nokia
                  "We must do something. This is something. Therefore, we must do this."
                  -- Antony Jay and Jonathan Lynn, "Yes Minister"

                  Comment

                  • Flash Gordon

                    #10
                    Re: Given a file pointer is there any way to get the fill path tothe file

                    parag_paul@hotm ail.com wrote, On 04/10/08 18:17:
                    On Oct 4, 2:26 am, vipps...@gmail. com wrote:
                    >On Oct 3, 11:29 pm, Keith Thompson <ks...@mib.orgw rote:
                    <snip>
                    >>comp.unix.pro grammer (check their FAQ(s) first).
                    >I've asked before, they don't have one :-(
                    >It'd be helpful.
                    >
                    A small question ,
                    where can I find the archives and is there a direct search to the same
                    Google Groups, through which you are posting, acts as an archive and
                    allows you to search! There are, I believe, other places that also
                    archive some groups. However, News Groups are not a centralised thing so
                    there is no one definitive archive (although Google tries to be one).
                    --
                    Flash Gordon
                    If spamming me sent it to smap@spam.cause way.com
                    If emailing me use my reply-to address
                    See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/

                    Comment

                    • christian.bau

                      #11
                      Re: Given a file pointer is there any way to get the fill path to thefile

                      On Oct 4, 1:21 am, Keith Thompson <ks...@mib.orgw rote:
                      A Unix FAQ is posted regularly to comp.unix.quest ions and
                      comp.unix.shell .  See, for example,
                      <http://www.faqs.org/faqs/unix-faq/faq/>.  Question 4.3 is "How do I
                      find the name of an open file?".  (The answer was written 15 years
                      ago, but I don't think anything has changed.)
                      Well, something has changed. From the answer: "Just realize that
                      searching a 600 megabyte filesystem for a file that may not even exist
                      is going to take some time." Filesystems with only 600 megabyte are
                      hard to find nowadays :-)


                      Comment

                      • Gordon Burditt

                        #12
                        Re: Given a file pointer is there any way to get the fill path to thefile

                        >Well, something has changed. From the answer: "Just realize that
                        >searching a 600 megabyte filesystem for a file that may not even exist
                        >is going to take some time."
                        Searching for the file on a 1TB filesystem will be even slower.
                        >Filesystems with only 600 megabyte are
                        >hard to find nowadays :-)
                        I disagree. CD-ROMs are limited to about 700 megabytes and it's not
                        uncommon to use less than that for smaller distributions.

                        It's true that *disk drives* and more recently *memory sticks* with
                        only 600 megabytes are hard to find. However, disks can be
                        partitioned, and a filesystem fits on one partition. There are
                        advantages to having a small root filesystem (say, 200MB, 50% full)
                        on UNIX: it's written to infrequently (except during system
                        upgrades), so the chances of corruption due to power failure or
                        accidental reset are low. Incremental backups are small. Filesystem
                        checks are faster. There is likely to be little or no user-owned
                        data on it. (It's assumed that such filesystems as /usr, /var,
                        /tmp, /usr/local, and /home are on mounted filesystems). Restoring
                        a root filesystem is a bit painful but it's less painful if the
                        backup is on one CD/DVD or memory stick.

                        Comment

                        Working...