|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #include <string.h>
- #include <stdio.h>
-
- #include "cms_util.h"
- #include "cms_err.h"
- #include "cms_files.h"
-
- int main(int argc, char** argv)
- {
- if (argc < 2)
- {
- fprintf(stderr, "Usage: %s <init|build>\n", argv[0]);
- return 1;
- }
-
- if (strcmp(argv[1], "init") == 0) //Initiate directory
- {
- if (argc != 3)
- {
- fprintf(stderr, "Usage: %s init <directory>\n", argv[0]);
- return 1;
- }
-
- char* dirname = argv[2];
-
- //Get the path of .cmsinited, which tells us
- //whether or not the directory is already inited
- char* initedPath = cms_util_path_join(dirname, CMS_FILE_INITED);
-
- //Panic if the directory is already initiated
- if (cms_util_file_exists(initedPath))
- cms_err_panic(CMS_ERR_INITED, NULL);
-
- //Create .cmsinited file
- cms_util_file_create(initedPath);
- }
-
- else if (strcmp(argv[1], "build") == 0) //Build
- {
- char* dirname = argv[2];
-
- //Get the path of .cmsinited, which tells us
- //whether or not the directory is already inited
- char* initedPath = cms_util_path_join(dirname, CMS_FILE_INITED);
-
- //Panic if the directory isn't initiated
- if (!cms_util_file_exists(initedPath))
- cms_err_panic(CMS_ERR_NOTINITED, NULL);
- }
- }
|