Move XDG_SUBDIR out of chat.h
This commit is contained in:
		
							parent
							
								
									ac4876718f
								
							
						
					
					
						commit
						a50596c5c5
					
				
							
								
								
									
										2
									
								
								chat.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								chat.h
									
									
									
									
									
								
							| @ -26,8 +26,6 @@ | ||||
| #define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0])) | ||||
| #define BIT(x) x##Bit, x = 1 << x##Bit, x##Bit_ = x##Bit | ||||
| 
 | ||||
| #define XDG_SUBDIR "catgirl" | ||||
| 
 | ||||
| typedef unsigned char byte; | ||||
| 
 | ||||
| int procPipe[2]; | ||||
|  | ||||
							
								
								
									
										14
									
								
								xdg.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								xdg.c
									
									
									
									
									
								
							| @ -24,6 +24,8 @@ | ||||
| 
 | ||||
| #include "chat.h" | ||||
| 
 | ||||
| #define SUBDIR "catgirl" | ||||
| 
 | ||||
| FILE *configOpen(const char *path, const char *mode) { | ||||
| 	if (path[0] == '/' || path[0] == '.') goto local; | ||||
| 
 | ||||
| @ -33,10 +35,10 @@ FILE *configOpen(const char *path, const char *mode) { | ||||
| 
 | ||||
| 	char buf[PATH_MAX]; | ||||
| 	if (configHome) { | ||||
| 		snprintf(buf, sizeof(buf), "%s/" XDG_SUBDIR "/%s", configHome, path); | ||||
| 		snprintf(buf, sizeof(buf), "%s/" SUBDIR "/%s", configHome, path); | ||||
| 	} else { | ||||
| 		if (!home) goto local; | ||||
| 		snprintf(buf, sizeof(buf), "%s/.config/" XDG_SUBDIR "/%s", home, path); | ||||
| 		snprintf(buf, sizeof(buf), "%s/.config/" SUBDIR "/%s", home, path); | ||||
| 	} | ||||
| 	FILE *file = fopen(buf, mode); | ||||
| 	if (file) return file; | ||||
| @ -49,7 +51,7 @@ FILE *configOpen(const char *path, const char *mode) { | ||||
| 	while (*configDirs) { | ||||
| 		size_t len = strcspn(configDirs, ":"); | ||||
| 		snprintf( | ||||
| 			buf, sizeof(buf), "%.*s/" XDG_SUBDIR "/%s", | ||||
| 			buf, sizeof(buf), "%.*s/" SUBDIR "/%s", | ||||
| 			(int)len, configDirs, path | ||||
| 		); | ||||
| 		file = fopen(buf, mode); | ||||
| @ -79,13 +81,13 @@ FILE *dataOpen(const char *path, const char *mode) { | ||||
| 	if (dataHome) { | ||||
| 		snprintf( | ||||
| 			homePath, sizeof(homePath), | ||||
| 			"%s/" XDG_SUBDIR "/%s", dataHome, path | ||||
| 			"%s/" SUBDIR "/%s", dataHome, path | ||||
| 		); | ||||
| 	} else { | ||||
| 		if (!home) goto local; | ||||
| 		snprintf( | ||||
| 			homePath, sizeof(homePath), | ||||
| 			"%s/.local/share/" XDG_SUBDIR "/%s", home, path | ||||
| 			"%s/.local/share/" SUBDIR "/%s", home, path | ||||
| 		); | ||||
| 	} | ||||
| 	FILE *file = fopen(homePath, mode); | ||||
| @ -100,7 +102,7 @@ FILE *dataOpen(const char *path, const char *mode) { | ||||
| 	while (*dataDirs) { | ||||
| 		size_t len = strcspn(dataDirs, ":"); | ||||
| 		snprintf( | ||||
| 			buf, sizeof(buf), "%.*s/" XDG_SUBDIR "/%s", | ||||
| 			buf, sizeof(buf), "%.*s/" SUBDIR "/%s", | ||||
| 			(int)len, dataDirs, path | ||||
| 		); | ||||
| 		file = fopen(buf, mode); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user