file comparision

Discussion in 'Programming' started by myth007_03, Apr 15, 2008.

  1. #1
    I am working on comparing to large files......
    i want to comapres blocks of two file. first is a file and second is updated file.
    If i will compare two files by given command or string by string it will take too long time. SO i think that i will compare blocks of two files and try to find out changes in file. But if one block in between is changed then all block below that are not able to match. Can any one help me in this.
    I wan to know how to access a block of a file?
    how to compare them??
     
    myth007_03, Apr 15, 2008 IP
  2. Arkserver

    Arkserver Banned

    Messages:
    2,533
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Depends how the file format it. plain text /encrypted etc..
     
    Arkserver, Apr 15, 2008 IP
  3. mikelaw

    mikelaw Peon

    Messages:
    148
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If it's a text file you could try Windiff or even the DOS fc command.
     
    mikelaw, Apr 22, 2008 IP
  4. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #4
    Simply reading the file in a specific block and compare, it is what WinDiff/DOS fc programs do.

    I PHP for example, I would do: fread($file,1024), which will read it in block of 1024 bytes.

    Peace,
     
    Barti1987, Apr 22, 2008 IP
  5. mikelaw

    mikelaw Peon

    Messages:
    148
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The difficulty with block comparisons is deciding what comprises a block. With text it is somewhat simplified since the data is broken into lines ending with \n and you can work out when blocks are alike. With other data it is not so simple and in the worst case a block may be 1 byte long making a comparison useless.
     
    mikelaw, Apr 23, 2008 IP