Loading ...
Sorry, an error occurred while loading the content.

UNIX_FILE_INFO: bug or misunderstanding?

Expand Messages
  • brucemount@aol.com
    Given two text files with different creation dates and any contents at: C: File_Test test_1.txt C: File_Test test_2.txt I was trying to see if file_1.txt had
    Message 1 of 4 , Apr 21 5:42 AM
    View Source
    • 0 Attachment
      Given two text files with different creation dates and any contents at:


      C:\File_Test\test_1.txt
      C:\File_Test\test_2.txt


      I was trying to see if file_1.txt had the same last-changed date as file_2.txt, using the program below. However, it appears that creating file_2 side-effects the file_info : UNIX_FILE_INFO object of file_1, making it appear that the date for file_1 and file_2 are always the same. The file_info object does not appear to be a once-function.


      Is this a bug or am I just doing something wrong?


      Thanks,


      --Bruce



      ============= Simplified program ==========================

      class
      FILE_TEST


      create
      make


      feature {NONE}
      make
      local
      file_1, file_2 : PLAIN_TEXT_FILE
      file_1_info, file_2_info : UNIX_FILE_INFO
      file_1_date, file_2_date : INTEGER
      do
      create file_1.make("C:\File_Test\test_1.txt")
      file_1_info := file_1.file_info
      file_1_date := file_1_info.date
      print(file_1_info.date.out + ", " + file_1_date.out + "%N")


      create file_2.make("C:\File_Test\test_2.txt")
      file_2_info := file_2.file_info
      file_2_date := file_2_info.date
      print(file_1_info.date.out + ", " + file_1_date.out + "%N") -- ERROR: values no longer match!
      print(file_2_info.date.out + ", " + file_2_date.out + "%N")
      end
      end


      =============== Output of the Program ==================
      1335009268, 1335009268
      1335010300, 1335009268
      1335010300, 1335010300


      ================ Comments ================
      Line 1 is correct: file_1_info.date matches the saved integer value for 'date'
      Line 2 is wrong! file_1_info.date NO LONGER MATCHES the saved integer value! It how has file_2 info.
      Line 3 is correct: file_2_info.date matches the saved integer value for 'date', but seems to have side-effected file_1_info





      [Non-text portions of this message have been removed]
    • brucemount@aol.com
      Sorry, I forgot to add, that I m using Eiffel 7.0. --B ... From: brucemount To: eiffel_software Sent:
      Message 2 of 4 , Apr 21 5:43 AM
      View Source
      • 0 Attachment
        Sorry, I forgot to add, that I'm using Eiffel 7.0.


        --B


        -----Original Message-----
        From: brucemount <brucemount@...>
        To: eiffel_software <eiffel_software@yahoogroups.com>
        Sent: Sat, Apr 21, 2012 8:42 am
        Subject: UNIX_FILE_INFO: bug or misunderstanding?


        Given two text files with different creation dates and any contents at:


        C:\File_Test\test_1.txt
        C:\File_Test\test_2.txt


        I was trying to see if file_1.txt had the same last-changed date as file_2.txt, using the program below. However, it appears that creating file_2 side-effects the file_info : UNIX_FILE_INFO object of file_1, making it appear that the date for file_1 and file_2 are always the same. The file_info object does not appear to be a once-function.


        Is this a bug or am I just doing something wrong?


        Thanks,


        --Bruce



        ============= Simplified program ==========================

        class
        FILE_TEST


        create
        make


        feature {NONE}
        make
        local
        file_1, file_2 : PLAIN_TEXT_FILE
        file_1_info, file_2_info : UNIX_FILE_INFO
        file_1_date, file_2_date : INTEGER
        do
        create file_1.make("C:\File_Test\test_1.txt")
        file_1_info := file_1.file_info
        file_1_date := file_1_info.date
        print(file_1_info.date.out + ", " + file_1_date.out + "%N")


        create file_2.make("C:\File_Test\test_2.txt")
        file_2_info := file_2.file_info
        file_2_date := file_2_info.date
        print(file_1_info.date.out + ", " + file_1_date.out + "%N") -- ERROR: values no longer match!
        print(file_2_info.date.out + ", " + file_2_date.out + "%N")
        end
        end


        =============== Output of the Program ==================
        1335009268, 1335009268
        1335010300, 1335009268
        1335010300, 1335010300


        ================ Comments ================
        Line 1 is correct: file_1_info.date matches the saved integer value for 'date'
        Line 2 is wrong! file_1_info.date NO LONGER MATCHES the saved integer value! It how has file_2 info.
        Line 3 is correct: file_2_info.date matches the saved integer value for 'date', but seems to have side-effected file_1_info






        [Non-text portions of this message have been removed]
      • Emmanuel Stapf
        The reason of this misbehavior is that the `file_info query returns the same underlying object. We will fix this in a future release. In the meantime, you
        Message 3 of 4 , Apr 23 10:49 AM
        View Source
        • 0 Attachment
          The reason of this misbehavior is that the `file_info' query returns the same
          underlying object. We will fix this in a future release. In the meantime, you
          should either use the FILE queries instead of going through the `file_info' query,
          or create the UNIX_FILE_INFO instances manually rather than getting it from FILE,
          i.e.

          create file_info.make
          file_info.update (file_name)

          Hope this helps,
          Manu

          > -----Original Message-----
          > From: eiffel_software@yahoogroups.com
          > [mailto:eiffel_software@yahoogroups.com] On Behalf Of brucemount@...
          > Sent: Saturday, April 21, 2012 5:43 AM
          > To: eiffel_software@yahoogroups.com
          > Subject: [eiffel_software] UNIX_FILE_INFO: bug or misunderstanding?
          >
          >
          > Given two text files with different creation dates and any contents at:
          >
          >
          > C:\File_Test\test_1.txt
          > C:\File_Test\test_2.txt
          >
          >
          > I was trying to see if file_1.txt had the same last-changed date as
          > file_2.txt, using the program below. However, it appears that creating
          > file_2 side-effects the file_info : UNIX_FILE_INFO object of file_1,
          > making it appear that the date for file_1 and file_2 are always the same.
          > The file_info object does not appear to be a once-function.
          >
          >
          > Is this a bug or am I just doing something wrong?
          >
          >
          > Thanks,
          >
          >
          > --Bruce
          >
          >
          >
          > ============= Simplified program ==========================
          >
          > class
          > FILE_TEST
          >
          >
          > create
          > make
          >
          >
          > feature {NONE}
          > make
          > local
          > file_1, file_2 : PLAIN_TEXT_FILE
          > file_1_info, file_2_info : UNIX_FILE_INFO
          > file_1_date, file_2_date : INTEGER
          > do
          > create file_1.make("C:\File_Test\test_1.txt")
          > file_1_info := file_1.file_info
          > file_1_date := file_1_info.date
          > print(file_1_info.date.out + ", " + file_1_date.out + "%N")
          >
          >
          > create file_2.make("C:\File_Test\test_2.txt")
          > file_2_info := file_2.file_info
          > file_2_date := file_2_info.date
          > print(file_1_info.date.out + ", " + file_1_date.out + "%N") -- ERROR:
          > values no longer match!
          > print(file_2_info.date.out + ", " + file_2_date.out + "%N")
          > end
          > end
          >
          >
          > =============== Output of the Program ==================
          > 1335009268, 1335009268
          > 1335010300, 1335009268
          > 1335010300, 1335010300
          >
          >
          > ================ Comments ================
          > Line 1 is correct: file_1_info.date matches the saved integer value for
          > 'date'
          > Line 2 is wrong! file_1_info.date NO LONGER MATCHES the saved integer
          > value! It how has file_2 info.
          > Line 3 is correct: file_2_info.date matches the saved integer value for
          > 'date', but seems to have side-effected file_1_info
          >
          >
          >
          >
          >
          > [Non-text portions of this message have been removed]
          >
          >
          >
          > ------------------------------------
          >
          > Yahoo! Groups Links
          >
          >
          >
        • brucemount@aol.com
          Thanks Manu! --Bruce [Non-text portions of this message have been removed]
          Message 4 of 4 , Apr 24 7:40 AM
          View Source
          • 0 Attachment
            Thanks Manu!


            --Bruce


            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.