PlatformIOSUtils.mm 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. /*
  8. Portions Copyright (c) 2013 Eugene Solodovnykov
  9. Permission is hereby granted, free of charge, to any person obtaining a copy
  10. of this software and associated documentation files (the "Software"), to deal
  11. in the Software without restriction, including without limitation the rights
  12. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. copies of the Software, and to permit persons to whom the Software is
  14. furnished to do so, subject to the following conditions:
  15. The above copyright notice and this permission notice shall be included in
  16. all copies or substantial portions of the Software.
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. THE SOFTWARE.
  24. */
  25. #import <Foundation/Foundation.h>
  26. #import <Security/Security.h>
  27. #include "PlatformIOSUtils.h"
  28. namespace ToolCore {
  29. String GetMobileProvisionData(const char* cfilename)
  30. {
  31. CMSDecoderRef decoder = NULL;
  32. CFDataRef dataRef = NULL;
  33. NSString *plistString = nil;
  34. //NSDictionary *plist = nil;
  35. NSString *file = [[NSString alloc] initWithBytes:cfilename
  36. length:strlen(cfilename)
  37. encoding:NSUTF8StringEncoding];
  38. @try {
  39. CMSDecoderCreate(&decoder);
  40. NSData *fileData = [NSData dataWithContentsOfFile:file];
  41. CMSDecoderUpdateMessage(decoder, fileData.bytes, fileData.length);
  42. CMSDecoderFinalizeMessage(decoder);
  43. CMSDecoderCopyContent(decoder, &dataRef);
  44. plistString = [[[NSString alloc] initWithData:(NSData *)dataRef encoding:NSUTF8StringEncoding] autorelease];
  45. //plist = [plistString propertyList];
  46. }
  47. @catch (NSException *exception) {
  48. printf("Could not decode file.\n");
  49. }
  50. @finally {
  51. if (decoder) CFRelease(decoder);
  52. if (dataRef) CFRelease(dataRef);
  53. }
  54. String value;
  55. if (plistString)
  56. {
  57. value = [plistString UTF8String];
  58. [plistString release];
  59. }
  60. [file release];
  61. return value;
  62. }
  63. }