plutil 的 跨平台版本,基于 PlistCpp.

废话不多,放马:

 

  1. #include <cstdio> 
  2. #include "Plist.hpp" 
  3.  
  4. using namespace std; 
  5.  
  6. typedef map<string, boost::any> Map; 
  7.  
  8. const char *link = "https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/plutil.1.html"
  9. const string plistHeader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); 
  10. const string suffix(".plist"); 
  11.  
  12. void usage(const char *name) 
  13.     printf("Example:\n"); 
  14.     printf("\t%s from.plist\n", name); 
  15.     printf("output file is (bin-/xml-)from.plist\n"); 
  16.     printf("\tMore detail at %s\n", link); 
  17.  
  18.  
  19. int main(int argc, char **argv) 
  20.     if (argc != 2)  
  21.     { 
  22.         usage(argv[0]); 
  23.         exit(1); 
  24.     } 
  25.  
  26.     bool xml = true
  27.     string stringLine;  
  28.     ifstream infile;   
  29.     infile.open (argv[1]); 
  30.     getline(infile,stringLine); 
  31.     if (stringLine != plistHeader) { 
  32.         xml = false
  33.     } 
  34.  
  35.     printf("%s is %s\n", argv[1], xml ? "xml format" : "binary format"); 
  36.  
  37.     /// read file 
  38.     Map dict;  
  39.     Plist::readPlist(argv[1], dict); 
  40.  
  41.     string outFile(argv[1]); 
  42.     outFile.erase(outFile.rfind(suffix), suffix.length()); 
  43.     if (xml) { 
  44.         outFile.append("-bin.plist"); 
  45.     } 
  46.     else { 
  47.         outFile.append("-xml.plist"); 
  48.     } 
  49.     printf("Convert %s to %s\n", argv[1], outFile.c_str()); 
  50.  
  51.     Plist::writePlistXML(outFile, dict); 
  52.  
  53.     printf("Convert finished!\n"); 
  54.     return 0; 

放出 win32 的下载链接;