OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkRTConf.h" | 8 #include "SkRTConf.h" |
9 #include "SkOSFile.h" | 9 #include "SkOSFile.h" |
10 | 10 |
11 #include <stdlib.h> | 11 #include <stdlib.h> |
12 | 12 |
13 SkRTConfRegistry::SkRTConfRegistry(): fConfs(100) { | 13 SkRTConfRegistry::SkRTConfRegistry(): fConfs(100) { |
14 | 14 |
15 SkFILE *fp = sk_fopen(configFileLocation(), kRead_SkFILE_Flag); | 15 FILE *fp = sk_fopen(configFileLocation(), kRead_SkFILE_Flag); |
16 | 16 |
17 if (!fp) { | 17 if (!fp) { |
18 return; | 18 return; |
19 } | 19 } |
20 | 20 |
21 char line[1024]; | 21 char line[1024]; |
22 | 22 |
23 while (!sk_feof(fp)) { | 23 while (!sk_feof(fp)) { |
24 | 24 |
25 if (!sk_fgets(line, sizeof(line), fp)) { | 25 if (!sk_fgets(line, sizeof(line), fp)) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 | 71 |
72 const char *SkRTConfRegistry::configFileLocation() const { | 72 const char *SkRTConfRegistry::configFileLocation() const { |
73 return "skia.conf"; // for now -- should probably do something fancier like
home directories or whatever. | 73 return "skia.conf"; // for now -- should probably do something fancier like
home directories or whatever. |
74 } | 74 } |
75 | 75 |
76 // dump all known runtime config options to the file with their default values. | 76 // dump all known runtime config options to the file with their default values. |
77 // to trigger this, make a config file of zero size. | 77 // to trigger this, make a config file of zero size. |
78 void SkRTConfRegistry::possiblyDumpFile() const { | 78 void SkRTConfRegistry::possiblyDumpFile() const { |
79 const char *path = configFileLocation(); | 79 const char *path = configFileLocation(); |
80 SkFILE *fp = sk_fopen(path, kRead_SkFILE_Flag); | 80 FILE *fp = sk_fopen(path, kRead_SkFILE_Flag); |
81 if (!fp) { | 81 if (!fp) { |
82 return; | 82 return; |
83 } | 83 } |
84 size_t configFileSize = sk_fgetsize(fp); | 84 size_t configFileSize = sk_fgetsize(fp); |
85 if (configFileSize == 0) { | 85 if (configFileSize == 0) { |
86 printAll(path); | 86 printAll(path); |
87 } | 87 } |
88 sk_fclose(fp); | 88 sk_fclose(fp); |
89 } | 89 } |
90 | 90 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 template void SkRTConfRegistry::set(const char *name, int value, bool); | 316 template void SkRTConfRegistry::set(const char *name, int value, bool); |
317 template void SkRTConfRegistry::set(const char *name, unsigned int value, bool); | 317 template void SkRTConfRegistry::set(const char *name, unsigned int value, bool); |
318 template void SkRTConfRegistry::set(const char *name, float value, bool); | 318 template void SkRTConfRegistry::set(const char *name, float value, bool); |
319 template void SkRTConfRegistry::set(const char *name, double value, bool); | 319 template void SkRTConfRegistry::set(const char *name, double value, bool); |
320 template void SkRTConfRegistry::set(const char *name, char * value, bool); | 320 template void SkRTConfRegistry::set(const char *name, char * value, bool); |
321 | 321 |
322 SkRTConfRegistry &skRTConfRegistry() { | 322 SkRTConfRegistry &skRTConfRegistry() { |
323 static SkRTConfRegistry r; | 323 static SkRTConfRegistry r; |
324 return r; | 324 return r; |
325 } | 325 } |
OLD | NEW |