stat_test.c 941 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2011-2012 Nokia Corporation and/or its subsidiary(-ies).
  3. * All rights reserved.
  4. * This component and the accompanying materials are made available
  5. * under the terms of the License "Eclipse Public License v1.0"
  6. * which accompanies this distribution, and is available
  7. * at the URL "http://www.eclipse.org/legal/epl-v10.html".
  8. *
  9. * Initial Contributors:
  10. * Nokia Corporation - initial contribution.
  11. *
  12. * Contributors:
  13. *
  14. * Description:
  15. *
  16. * Program for testing stat function call on filesystem
  17. */
  18. #include <fcntl.h>
  19. #include <dirent.h>
  20. #include <sys/types.h>
  21. #include <sys/stat.h>
  22. #include <unistd.h>
  23. #include <errno.h>
  24. #include <string.h>
  25. #include <stdio.h>
  26. #define EOK 0
  27. #define ENOPATH 1
  28. int main(int argc, char *argv[])
  29. {
  30. struct stat stb;
  31. int statres;
  32. if (argc > 1)
  33. {
  34. access(argv[1], R_OK);
  35. statres = stat(argv[1], &stb);
  36. }
  37. else
  38. {
  39. fprintf(stderr,"Not enough args\n");
  40. }
  41. return statres;
  42. }