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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. What is a file?

What is a file?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomalgorithmsdata-structuresperformance
7 Posts 4 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.
  • D Offline
    D Offline
    Dimitris Vikeloudas
    wrote on last edited by
    #1

    Hi I am trying to understand what file is in Win32 system and how to access. Let me be more specific. I am comming from the UNIX word where a file is an area in the disk in a location pointed out by a "unique" integer number known as the inode. Each process then traditionaly has an array of 15 file handles and any time a file is opened is is associated with one entry on the that array. The array number is the file handle and numbers from 0 to 2 are the standard ones. For higher lever IO there is the standard FILE structure which is associated with one of the FILE handles. In windows you have the HANLDES that are returned by CreateFile, the CFILE classes and on top of that the Unix compatibility functions like _open() to open the whatever UNIX style handles. I am trying to make sense of those (whithout the complexity of named pipes, memory ereas etc) as I think I make sense the UNIX/C interface. I am looking for a document to explain i. How an area in a disk is related with file structures ii. What is the meaning representation of compatibility functions in Win32? E.g. for my own inverstigation I found that the _stat (aka stat of UNIX) returns always the same inode number whatever the file is. iii. How can I related the different handles logically. I saw hadles document which explains how to convert from one to the other but how they are related? iv. How the files, the HANLDE and processes are related. Any help will be much appreciated. Life is a river with mist ahead...

    D J B 3 Replies Last reply
    0
    • D Dimitris Vikeloudas

      Hi I am trying to understand what file is in Win32 system and how to access. Let me be more specific. I am comming from the UNIX word where a file is an area in the disk in a location pointed out by a "unique" integer number known as the inode. Each process then traditionaly has an array of 15 file handles and any time a file is opened is is associated with one entry on the that array. The array number is the file handle and numbers from 0 to 2 are the standard ones. For higher lever IO there is the standard FILE structure which is associated with one of the FILE handles. In windows you have the HANLDES that are returned by CreateFile, the CFILE classes and on top of that the Unix compatibility functions like _open() to open the whatever UNIX style handles. I am trying to make sense of those (whithout the complexity of named pipes, memory ereas etc) as I think I make sense the UNIX/C interface. I am looking for a document to explain i. How an area in a disk is related with file structures ii. What is the meaning representation of compatibility functions in Win32? E.g. for my own inverstigation I found that the _stat (aka stat of UNIX) returns always the same inode number whatever the file is. iii. How can I related the different handles logically. I saw hadles document which explains how to convert from one to the other but how they are related? iv. How the files, the HANLDE and processes are related. Any help will be much appreciated. Life is a river with mist ahead...

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Dimitris Vikeloudas wrote: E.g. for my own inverstigation I found that the _stat (aka stat of UNIX) returns always the same inode number whatever the file is. Which is what the documentation says it will do on FAT, HPFS, or NTFS file systems. It is a UNIX-specific value. Dimitris Vikeloudas wrote: iii. How can I related the different handles logically. What exactly do you mean by this? A handle is nothing more than an object identifier. You have a handle: Dimitris Vikeloudas. It is what's used when we want to communicate with you (except that we do not destroy yours when we are done!). Dimitris Vikeloudas wrote: iv. How the files, the HANLDE and processes are related. There is no relationship, except that a process can "own" zero or more handles. Per MSDN, a process is a running application that consists of a private virtual address space, code, data, and other operating-system resources, such as files, pipes, and synchronization objects that are visible to the process. A process also contains one or more threads that run in the context of the process. A handle is a a variable that contains the address of another variable, which in turn contains the address of the desired object, or a token that an application can use to identify and access an object such as a device, a file, a window, or a dialog box.


      "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

      D 1 Reply Last reply
      0
      • D Dimitris Vikeloudas

        Hi I am trying to understand what file is in Win32 system and how to access. Let me be more specific. I am comming from the UNIX word where a file is an area in the disk in a location pointed out by a "unique" integer number known as the inode. Each process then traditionaly has an array of 15 file handles and any time a file is opened is is associated with one entry on the that array. The array number is the file handle and numbers from 0 to 2 are the standard ones. For higher lever IO there is the standard FILE structure which is associated with one of the FILE handles. In windows you have the HANLDES that are returned by CreateFile, the CFILE classes and on top of that the Unix compatibility functions like _open() to open the whatever UNIX style handles. I am trying to make sense of those (whithout the complexity of named pipes, memory ereas etc) as I think I make sense the UNIX/C interface. I am looking for a document to explain i. How an area in a disk is related with file structures ii. What is the meaning representation of compatibility functions in Win32? E.g. for my own inverstigation I found that the _stat (aka stat of UNIX) returns always the same inode number whatever the file is. iii. How can I related the different handles logically. I saw hadles document which explains how to convert from one to the other but how they are related? iv. How the files, the HANLDE and processes are related. Any help will be much appreciated. Life is a river with mist ahead...

        J Offline
        J Offline
        John M Drescher
        wrote on last edited by
        #3

        Dimitris Vikeloudas wrote: i. How an area in a disk is related with file structures No relation at all. John

        1 Reply Last reply
        0
        • D Dimitris Vikeloudas

          Hi I am trying to understand what file is in Win32 system and how to access. Let me be more specific. I am comming from the UNIX word where a file is an area in the disk in a location pointed out by a "unique" integer number known as the inode. Each process then traditionaly has an array of 15 file handles and any time a file is opened is is associated with one entry on the that array. The array number is the file handle and numbers from 0 to 2 are the standard ones. For higher lever IO there is the standard FILE structure which is associated with one of the FILE handles. In windows you have the HANLDES that are returned by CreateFile, the CFILE classes and on top of that the Unix compatibility functions like _open() to open the whatever UNIX style handles. I am trying to make sense of those (whithout the complexity of named pipes, memory ereas etc) as I think I make sense the UNIX/C interface. I am looking for a document to explain i. How an area in a disk is related with file structures ii. What is the meaning representation of compatibility functions in Win32? E.g. for my own inverstigation I found that the _stat (aka stat of UNIX) returns always the same inode number whatever the file is. iii. How can I related the different handles logically. I saw hadles document which explains how to convert from one to the other but how they are related? iv. How the files, the HANLDE and processes are related. Any help will be much appreciated. Life is a river with mist ahead...

          B Offline
          B Offline
          bghuang
          wrote on last edited by
          #4

          There are 2 main structures in Windows system: FAT32 & NTFS. The NTFS system is similar to the UNIX ,But the FAT32 are not. you can search the topic about FAT32 from MSDN or Google.:laugh:

          1 Reply Last reply
          0
          • D David Crow

            Dimitris Vikeloudas wrote: E.g. for my own inverstigation I found that the _stat (aka stat of UNIX) returns always the same inode number whatever the file is. Which is what the documentation says it will do on FAT, HPFS, or NTFS file systems. It is a UNIX-specific value. Dimitris Vikeloudas wrote: iii. How can I related the different handles logically. What exactly do you mean by this? A handle is nothing more than an object identifier. You have a handle: Dimitris Vikeloudas. It is what's used when we want to communicate with you (except that we do not destroy yours when we are done!). Dimitris Vikeloudas wrote: iv. How the files, the HANLDE and processes are related. There is no relationship, except that a process can "own" zero or more handles. Per MSDN, a process is a running application that consists of a private virtual address space, code, data, and other operating-system resources, such as files, pipes, and synchronization objects that are visible to the process. A process also contains one or more threads that run in the context of the process. A handle is a a variable that contains the address of another variable, which in turn contains the address of the desired object, or a token that an application can use to identify and access an object such as a device, a file, a window, or a dialog box.


            "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

            D Offline
            D Offline
            Dimitris Vikeloudas
            wrote on last edited by
            #5

            Hi. Thanks very much. Your definition of the process it is enlightening. So for a file you have a HANLDE pointing to a handle structure pointing to a file structure related to disk. That's what I am getting. Is any similar chain for the CFile object? Also what happen with the UNIX compatibility functions like open. Is the integer that they return a handle casted to int or a is there an array of file descriptors that the C runtime environment maintains to emulate the UNIX process structure? And what about stdio FILE structures? How do they know the access tokens of the files that they correspond. Simply what I am trying to understand is what is the relationship between an area in a disk and the logical structures. I think you answered what a HANDLE does on that. If you know any documentation going to all these details will be much appreciated. life is a river with mist ahead..

            J 2 Replies Last reply
            0
            • D Dimitris Vikeloudas

              Hi. Thanks very much. Your definition of the process it is enlightening. So for a file you have a HANLDE pointing to a handle structure pointing to a file structure related to disk. That's what I am getting. Is any similar chain for the CFile object? Also what happen with the UNIX compatibility functions like open. Is the integer that they return a handle casted to int or a is there an array of file descriptors that the C runtime environment maintains to emulate the UNIX process structure? And what about stdio FILE structures? How do they know the access tokens of the files that they correspond. Simply what I am trying to understand is what is the relationship between an area in a disk and the logical structures. I think you answered what a HANDLE does on that. If you know any documentation going to all these details will be much appreciated. life is a river with mist ahead..

              J Offline
              J Offline
              John M Drescher
              wrote on last edited by
              #6

              Dimitris Vikeloudas wrote: And what about stdio FILE structures? How do they know the access tokens of the files that they correspond. They do not. They use the default rights of the logged on user. If you want deal with security you need to use CreateFile and the windows API directly. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceobjst/html/cerefCreateFile.asp[^] John

              1 Reply Last reply
              0
              • D Dimitris Vikeloudas

                Hi. Thanks very much. Your definition of the process it is enlightening. So for a file you have a HANLDE pointing to a handle structure pointing to a file structure related to disk. That's what I am getting. Is any similar chain for the CFile object? Also what happen with the UNIX compatibility functions like open. Is the integer that they return a handle casted to int or a is there an array of file descriptors that the C runtime environment maintains to emulate the UNIX process structure? And what about stdio FILE structures? How do they know the access tokens of the files that they correspond. Simply what I am trying to understand is what is the relationship between an area in a disk and the logical structures. I think you answered what a HANDLE does on that. If you know any documentation going to all these details will be much appreciated. life is a river with mist ahead..

                J Offline
                J Offline
                John M Drescher
                wrote on last edited by
                #7

                Dimitris Vikeloudas wrote: Simply what I am trying to understand is what is the relationship between an area in a disk and the logical structures. I do not believe windows gives the user access to any of the kernel structures it uses to read/write files. At most you get a handle tell the kernel what hidden (to the application) structure to use to access the file. CFile, stdio, and streams all use the Windows api CreateFile, ReadFile, WriteFile and CloseHandle to open/create, read, write and close files. John

                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