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 <stdlib.h> 17 #include <fcntl.h> // For O_WRONLY in BeOS R5 headers. 18 #include <kernel/fs_attr.h> 19 20 int main(int32 argc, const char **argv) 21 { 22 // Make sure we have the minimum number of arguments. 23 if (argc < 3) { 24 printf("usage: %s attr filename1 [filename2...]\n", argv[0]); 25 printf(" attr is the name of an attribute of the file\n"); 26 exit(0); 27 } 28 29 for(int32 i=2; i<argc; i++) { 30 int fd = open(argv[i], O_WRONLY); 31 if (fd < 0) { 32 fprintf( stderr, "%s: can\'t open file %s to remove attribute\n", 33 argv[0], argv[i]); 34 exit(0); 35 } 36 37 if(fs_remove_attr(fd, argv[1])!=B_OK) { 38 fprintf( stderr, "%s: error removing attribute %s from %s : No such attribute\n", 39 argv[0], argv[1], argv[i] ); 40 } 41 } 42 43 exit(0); 44 } 45