This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CF programming

Hi all,
Can any one tell how to implement search command for data search from compact flash card?

Parents
  • Search of files, or search of contents in files?

    Search of files - check out what functions there are for retrieving all entries in a directory. Implement a stack for found directories and iterate through all entries. Exactly what code are you using to access the file system?

    Search in files - completely depending on what to search for. But you have to read in the data in suitable chunks. Then it will be similar to searching for something in memory.

    Any reason why you thought your post needed to be written in bold?

Reply
  • Search of files, or search of contents in files?

    Search of files - check out what functions there are for retrieving all entries in a directory. Implement a stack for found directories and iterate through all entries. Exactly what code are you using to access the file system?

    Search in files - completely depending on what to search for. But you have to read in the data in suitable chunks. Then it will be similar to searching for something in memory.

    Any reason why you thought your post needed to be written in bold?

Children
  • i want to search a perticular file in card
    can you give me any sample code

  • What you do you mean?

    You want to find a specific file on the card? Like locating any file named *.lst

    You want to search for something in a specific file?
    Then open the file and read the contents and look for your pattern.

    Something else?

    Sample code for what?

    Full source code for a CF implementation, including FAT16 and FAT32 with long file names?

  • I want to find a specific file name on the card.
    If possible give me the source code for CF implementation

  • You want to find a specific file name?

    1) You know the full name of the file?

    2) Or you know the file name, but not in what directory it may be located?

    If 1, then just open the file.

    If 2, then you need to walk through all directory entries. But the code needed to do that is depending on what code you have to implement the file system support. I asked in my first post about this, but you still haven't answered: Exactly what code are you using to access the file system? Or don't you have any code at all to support accessing CF memory and accessing the file system on the CF memory?

  • Thanks for u r early response.
    Implementing FAT 16 file system.
    Want a command to search particular file from CF card by giving total path of the file.
    I am placing a file in a directory. While searching that file I know total path where I placed it. EX: I have a file “test.txt†in \time\min\sec\test.txt
    I want to get the file test.txt present in given directory path.Implementing the code in c language.

  • If you are implementing a FAT16 file system, then obviously no one but you can write example code for implementing the underlying code for an fopen() function using your file system?

    Locate root directory.
    Read first cluster.
    Scan for file name - or first directory in the path of your file name.
    If not found, locate next cluster of root directory repeat the search.

    If file found in root directory, then you are done.
    If not, locate first cluster of the subdirectory where the file is in.
    Read in and scan for the file name (or next level of the path).

    Repeat the above until you either fail (path or file missing) or you have found the file.

    If file is found, then you know the start cluster of the file. The FAT table will contain the chain of clusters to follow. The directory entry will contain the size of the file, which implies the number of clusters used by the file.