/[Sims3RigEditor]/trunk/gr2lib_cpp/GrannyFileWriter.cpp
ViewVC logotype

Contents of /trunk/gr2lib_cpp/GrannyFileWriter.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 55 - (show annotations) (download)
Thu Aug 12 08:37:47 2010 UTC (9 years, 6 months ago) by william
File size: 2139 byte(s)
Fix all, current, c++ compiler warnings and linker errors

1 #define _CRT_SECURE_NO_WARNINGS
2 #include "StdAfx.h"
3 #include "GrannyFileWriter.h"
4
5 //bool GrannyFileWriter::WriteFile(const char* filename, granny_file_info* info)
6 //{
7 // granny_file_builder *Builder = GrannyBeginFile(1, GrannyCurrentGRNStandardTag,
8 // GrannyGRNFileMV_32Bit_BigEndian,
9 // GrannyGetTemporaryDirectory(),
10 // "GRNFileTemp");
11 // granny_file_data_tree_writer *Writer =
12 // GrannyBeginFileDataTreeWriting(GrannyFileInfoType,info, 0, 0);
13 // GrannyWriteDataTreeToFileBuilder(Writer, Builder);
14 // GrannyEndFileDataTreeWriting(Writer);
15 //
16 // bool success = GrannyEndFile(Builder, filename);
17 // return success;
18 //}
19 bool GrannyFileWriter::WriteFile(const char* filename, granny_file_info* info, GrannyAPILogger* logger)
20 {
21 granny_file_builder *Builder = GrannyBeginFile(1, GrannyCurrentGRNStandardTag,
22 GrannyGRNFileMV_ThisPlatform,
23 GrannyGetTemporaryDirectory(),
24 "GRNFileTemp");
25 granny_file_data_tree_writer *Writer =
26 GrannyBeginFileDataTreeWriting(GrannyFileInfoType,info, 0, 0);
27 GrannyWriteDataTreeToFileBuilder(Writer, Builder);
28 GrannyEndFileDataTreeWriting(Writer);
29
30 bool success = GrannyEndFile(Builder, filename);
31
32 const char* FailedMessage = "Failed to Write: ";
33 const char* SuccessMessage = "Successfully Wrote: ";
34
35 int msg_failed_malloc = (strlen(FailedMessage) + strlen(filename));
36 int msg_success_malloc = (strlen(SuccessMessage) + strlen(filename));
37
38 char* msg_failed = (char*)malloc(msg_failed_malloc);
39 for (int i=0; i<msg_failed_malloc; i++) {
40 msg_failed[i] = 0; // Initialize all elements to zero.
41 }
42 char* msg_success = (char*)malloc(msg_success_malloc);
43 for (int i=0; i<msg_success_malloc; i++) {
44 msg_success[i] = 0; // Initialize all elements to zero.
45 }
46
47 strcat(msg_failed,FailedMessage);
48 strcat(msg_failed,filename);
49 strcat(msg_failed,"\n");
50
51 strcat(msg_success,SuccessMessage);
52 strcat(msg_success,filename);
53 strcat(msg_success,"\n");
54
55 if (logger != NULL)
56 {
57 if (!success)
58 {
59 logger->LogMessage(msg_failed);
60 }
61 else
62 {
63 logger->LogMessage(msg_success);
64 }
65 }
66 return success;
67 }

  ViewVC Help
Powered by ViewVC 1.1.22