TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kmimemagictest.cpp 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (C) 2002 David Faure <faure@kde.org>
  3. * Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License version 2 as published by the Free Software Foundation;
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public License
  15. * along with this library; see the file COPYING.LIB. If not, write to
  16. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #include <kmimetype.h>
  20. #include <kmimemagic.h>
  21. #include <kinstance.h>
  22. #include <stdio.h>
  23. int main( int argc, char** argv )
  24. {
  25. if (argc != 2)
  26. {
  27. printf("\n"
  28. "Usage : ./kmimemagictest file\n");
  29. return 1;
  30. }
  31. TDEInstance blah("kmimemagictest");
  32. TQString file = TQString::fromLocal8Bit( argv[1] );
  33. KMimeMagicResult * result = KMimeMagic::self()->findFileType( file );
  34. if ( result->isValid() )
  35. printf( "Found %s, accuracy %d\n", result->mimeType().latin1(), result->accuracy() );
  36. else
  37. printf( "Invalid result\n");
  38. KMimeType::Format f = KMimeType::findFormatByFileContent( file );
  39. if (f.text)
  40. printf("Text\n");
  41. else
  42. printf("Binary\n");
  43. if (f.compression == KMimeType::Format::GZipCompression)
  44. printf("GZipped\n");
  45. return 0;
  46. }