parameter is optional, defaults to '.'
This commit is contained in:
		
							
								
								
									
										15
									
								
								shperm.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								shperm.c
									
									
									
									
									
								
							@@ -121,15 +121,22 @@ void dumpLines() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char* argv[]) {
 | 
					int main(int argc, char* argv[]) {
 | 
				
			||||||
    if (argc != 2) {
 | 
					    if (argc > 2) {
 | 
				
			||||||
        fprintf(stderr, "Usage: %s <file or directory>\n", argv[0]);
 | 
					        fprintf(stderr, "Usage: %s [file or directory]\n", argv[0]);
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    char* path;
 | 
					    char* path;
 | 
				
			||||||
 | 
					    char* startpath;
 | 
				
			||||||
    path = malloc(PATH_MAX);
 | 
					    path = malloc(PATH_MAX);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (argc == 1) {
 | 
				
			||||||
 | 
					    	startpath = ".";
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					    	startpath = argv[1];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    if (realpath(argv[1], path)) {
 | 
					    if (realpath(startpath, path)) {
 | 
				
			||||||
        char* base;
 | 
					        char* base;
 | 
				
			||||||
        do {
 | 
					        do {
 | 
				
			||||||
            struct stat sb;
 | 
					            struct stat sb;
 | 
				
			||||||
@@ -151,4 +158,4 @@ int main(int argc, char* argv[]) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    free(path);
 | 
					    free(path);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user