SourceFiles.org - Use the Source, Luke
Home | Register | News | Forums | Guide | MyLinks | Bookmark

Related Sites

Latest News
  General News
  Reviews
  Press Releases
  Software
  Hardware
  Security
  Tutorials
  Off Topic


Back to files
WHAT IS

DiscDB is a little program that will use MySQL to catalog all files in your CDs, making it easy to find a file without having to switch discs until you find it. Useful for people who save all their downloads to CD-Rs(like me).


REQUIREMENTS
  • Linux 2.x
    • tested on a RedHat system with 2.4.0-test10 kernel
    • according to man pages, it should work on most POSIXes, BSDs and System Vs
  • MySQL
    • tested with 3.22.32 using UNIX sockets and TCP sockets
  • MySQL++
    • tested with 1.6.0
  • Readline
    • tested with 4.1
    • the 3.x that comes with RedHat 6.2 is known not to work with this syntax
    • needs Termcap - tested with 10.2.7-9
  • Parsecfg is needed but has been included

HOW TO COMPILE

Good old compilation sequence:

  • Edit Makefile and make sure the values are correct $ make dep $ make

It should build ok with this.


HOW TO INSTALL

Then again, good old way:

  • Make sure "INSTALLDIR" points to where you want the program to be installed, excluding "/bin", "/doc", etc.
  • Make sure the values in the config file(discdb.conf) are correct. $ make install

To uninstall it:

  • Make sure "INSTALLDIR" points to where the program is installed, excluding "/bin", "/doc", etc. $ make uninstall

To have it create the database structure automatically:

$ make createdb


HOW TO REPACK

If you make any changes to the program, you can repack it with any of the following commands:

    $ make packtgz        (to repack in .tar.gz format)
    $ make packbz2        (to repack in .tar.bz2 format)
    $ make packrpm        (to create .src.rpm and .xxx.rpm)
    $ make packall        (to create all of the above)

USAGE

The syntax is very simple:

  • To add a disc to the database:

$ discdb add <mountpoint>

        where <mountpoint> is the directory where the disc is mounted.
        For example:
         $ discdb add /mnt/cdrom

        You can also specify the disc title in the command line, with the -V
        option:
         $ discdb add /mnt/cdrom -V "My Backup Disk"
        Remember to enclose the title between quotes if it contains spaces.

        Note: as of yet, empty directories are not saved.
  • To delete a disc from the database by discID:

$ discdb delete <id>

where <id> is the ID of the disc you wish to delete.

  • To delete a disc from the database by title:

$ discdb tdelete <title>

        where <title> is the title of the disc as it is in the database.
        Enclose this between quotes if it contains spaces.
        For example:
         $ discdb delete "My Backup Disk"
  • To search for a file:

$ discdb search <pattern>

        where <pattern> can be anything like *.doc, myfile, etc.
        For more complex searches I suggest you use an SQL query directly. The 
        standard query is:

        SELECT  discs.title,
                files.name,
                files.size,
                files.date,
                files.misc,
                dirs.name
         FROM files
          LEFT JOIN discs
           ON files.discid=discs.discid
          LEFT JOIN dirs
           ON files.dirid=discs.dirid
         WHERE files.name LIKE "<pattern>" AND files.name != ".";

        only changing all "*"s for "%"s and "?"s for "_"s in the pattern 
        string. Please note that for that reason you can use both shell-like
        and SQL-style pattern strings in the command line. If you want to use
        "_" as part of the filename, enter it as "\_".
  • To search for a directory:

$ discdb dsearch <pattern>

        where <pattern> can be anything like *.ext, /mydir, etc.
        If the directory doesn't start with "/", discdb will add it.

        The SQL query used by this command is the following:

        SELECT DISTINCT discs.title,
                        dirs.name,
                        dirs.dirid
         FROM dirs
          LEFT JOIN files
           ON files.dirid=dirs.dirid
          LEFT JOIN discs
           ON discs.discid=files.discid
          WHERE dirs.name LIKE "<pattern>"
          ORDER BY dirs.dirid;

        and the results are displayed in the following format:

        Dir1:
         Discs where dir1 exists
        Dir2:
         Discs where dir2 exists
        and so on...
  • To optimize the database:

$ discdb optimize

        This will search for and delete unused directories, then run a 
        "OPTIMIZE TABLE" on all tables.
        Note: This may take several MINUTES depending on the size of your
        database.
  • To list all discs in the database:

$ discdb list

  • To see statistics about your disc database:

$ discdb stats


CONFIG FILE

The program looks for the config file in /usr/local/etc/discdb.conf(or wherever is specified in discdb.h) and then in ~/.discdb.conf. In case both files are found, both are read, and duplicate values are kept only from the one in your home directory. The format of these files is simple:

HOST = my.sql.host.com
USER = myusername
PASSWD = mysqlpassword

Other configurable options may be added in the future, but that's it for now.


ABOUT SPECIAL FILES

Devices and other special files(sockets, FIFOs, etc.) are indexed as well. The extra information such as major/minor, link target, etc. is stored in the "misc" field. The format of this field depends on the file type:

Char - major,minor
Block - major,minor,ideal_block_size Link - /where/the/link/points/to
FIFO - blank
Socket - blank

For files, you can use this field to add notes or dscriptions to specific files.


BUGS

None are known, but there probably are a few...if you find one, e-mail me at <cuddly@uol.com.br>.


TODO

See file ChangeLog.


VERSION HISTORY

See file ChangeLog.


Other Sites

Discussion Groups
  Beginners
  Distributions
  Networking / Security
  Software
  PDAs

About | FAQ | Privacy | Awards | Contact
Comments to the webmaster are welcome.
Copyright 2006 Sourcefiles.org All rights reserved.