1 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 2 // 3 // Copyright (c) 2001-2003, OpenBeOS 4 // 5 // This software is part of the OpenBeOS distribution and is covered 6 // by the OpenBeOS license. 7 // 8 // 9 // File: rmattr.cpp 10 // Author: Jérôme Duval 11 // Description: remove an attribute from a file 12 // 13 // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 14 15 #include <stdio.h> 16 #include <kernel/fs_attr.h> 17 18 int main(int32 argc, const char **argv) 19 { 20 // Make sure we have the minimum number of arguments. 21 if (argc < 3) { 22 printf("usage: %s attr filename1 [filename2...]\n", argv[0]); 23 printf(" attr is the name of an attribute of the file\n"); 24 exit(0); 25 } 26 27 for(int32 i=2; i<argc; i++) { 28 int fd = open(argv[i], O_WRONLY); 29 if (fd < 0) { 30 fprintf( stderr, "%s: can\'t open file %s to remove attribute\n", 31 argv[0], argv[i]); 32 exit(0); 33 } 34 35 if(fs_remove_attr(fd, argv[1])!=B_OK) { 36 fprintf( stderr, "%s: error removing attribute %s from %s : No such attribute\n", 37 argv[0], argv[1], argv[i] ); 38 } 39 } 40 41 exit(0); 42 } 43