diff --git a/cocos/2d/actions/CCAction.cpp b/cocos/2d/CCAction.cpp
similarity index 100%
rename from cocos/2d/actions/CCAction.cpp
rename to cocos/2d/CCAction.cpp
diff --git a/cocos/2d/actions/CCAction.h b/cocos/2d/CCAction.h
similarity index 100%
rename from cocos/2d/actions/CCAction.h
rename to cocos/2d/CCAction.h
diff --git a/cocos/2d/actions/CCActionCamera.cpp b/cocos/2d/CCActionCamera.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionCamera.cpp
rename to cocos/2d/CCActionCamera.cpp
diff --git a/cocos/2d/actions/CCActionCamera.h b/cocos/2d/CCActionCamera.h
similarity index 100%
rename from cocos/2d/actions/CCActionCamera.h
rename to cocos/2d/CCActionCamera.h
diff --git a/cocos/2d/actions/CCActionCatmullRom.cpp b/cocos/2d/CCActionCatmullRom.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionCatmullRom.cpp
rename to cocos/2d/CCActionCatmullRom.cpp
diff --git a/cocos/2d/actions/CCActionCatmullRom.h b/cocos/2d/CCActionCatmullRom.h
similarity index 100%
rename from cocos/2d/actions/CCActionCatmullRom.h
rename to cocos/2d/CCActionCatmullRom.h
diff --git a/cocos/2d/actions/CCActionEase.cpp b/cocos/2d/CCActionEase.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionEase.cpp
rename to cocos/2d/CCActionEase.cpp
diff --git a/cocos/2d/actions/CCActionEase.h b/cocos/2d/CCActionEase.h
similarity index 100%
rename from cocos/2d/actions/CCActionEase.h
rename to cocos/2d/CCActionEase.h
diff --git a/cocos/2d/actions/CCActionGrid.cpp b/cocos/2d/CCActionGrid.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionGrid.cpp
rename to cocos/2d/CCActionGrid.cpp
diff --git a/cocos/2d/actions/CCActionGrid.h b/cocos/2d/CCActionGrid.h
similarity index 100%
rename from cocos/2d/actions/CCActionGrid.h
rename to cocos/2d/CCActionGrid.h
diff --git a/cocos/2d/actions/CCActionGrid3D.cpp b/cocos/2d/CCActionGrid3D.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionGrid3D.cpp
rename to cocos/2d/CCActionGrid3D.cpp
diff --git a/cocos/2d/actions/CCActionGrid3D.h b/cocos/2d/CCActionGrid3D.h
similarity index 100%
rename from cocos/2d/actions/CCActionGrid3D.h
rename to cocos/2d/CCActionGrid3D.h
diff --git a/cocos/2d/actions/CCActionInstant.cpp b/cocos/2d/CCActionInstant.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionInstant.cpp
rename to cocos/2d/CCActionInstant.cpp
diff --git a/cocos/2d/actions/CCActionInstant.h b/cocos/2d/CCActionInstant.h
similarity index 100%
rename from cocos/2d/actions/CCActionInstant.h
rename to cocos/2d/CCActionInstant.h
diff --git a/cocos/2d/actions/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionInterval.cpp
rename to cocos/2d/CCActionInterval.cpp
diff --git a/cocos/2d/actions/CCActionInterval.h b/cocos/2d/CCActionInterval.h
similarity index 100%
rename from cocos/2d/actions/CCActionInterval.h
rename to cocos/2d/CCActionInterval.h
diff --git a/cocos/2d/actions/CCActionManager.cpp b/cocos/2d/CCActionManager.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionManager.cpp
rename to cocos/2d/CCActionManager.cpp
diff --git a/cocos/2d/actions/CCActionManager.h b/cocos/2d/CCActionManager.h
similarity index 100%
rename from cocos/2d/actions/CCActionManager.h
rename to cocos/2d/CCActionManager.h
diff --git a/cocos/2d/actions/CCActionPageTurn3D.cpp b/cocos/2d/CCActionPageTurn3D.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionPageTurn3D.cpp
rename to cocos/2d/CCActionPageTurn3D.cpp
diff --git a/cocos/2d/actions/CCActionPageTurn3D.h b/cocos/2d/CCActionPageTurn3D.h
similarity index 100%
rename from cocos/2d/actions/CCActionPageTurn3D.h
rename to cocos/2d/CCActionPageTurn3D.h
diff --git a/cocos/2d/actions/CCActionProgressTimer.cpp b/cocos/2d/CCActionProgressTimer.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionProgressTimer.cpp
rename to cocos/2d/CCActionProgressTimer.cpp
diff --git a/cocos/2d/actions/CCActionProgressTimer.h b/cocos/2d/CCActionProgressTimer.h
similarity index 100%
rename from cocos/2d/actions/CCActionProgressTimer.h
rename to cocos/2d/CCActionProgressTimer.h
diff --git a/cocos/2d/actions/CCActionTiledGrid.cpp b/cocos/2d/CCActionTiledGrid.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionTiledGrid.cpp
rename to cocos/2d/CCActionTiledGrid.cpp
diff --git a/cocos/2d/actions/CCActionTiledGrid.h b/cocos/2d/CCActionTiledGrid.h
similarity index 100%
rename from cocos/2d/actions/CCActionTiledGrid.h
rename to cocos/2d/CCActionTiledGrid.h
diff --git a/cocos/2d/actions/CCActionTween.cpp b/cocos/2d/CCActionTween.cpp
similarity index 100%
rename from cocos/2d/actions/CCActionTween.cpp
rename to cocos/2d/CCActionTween.cpp
diff --git a/cocos/2d/actions/CCActionTween.h b/cocos/2d/CCActionTween.h
similarity index 100%
rename from cocos/2d/actions/CCActionTween.h
rename to cocos/2d/CCActionTween.h
diff --git a/cocos/2d/sprite-nodes/CCAnimation.cpp b/cocos/2d/CCAnimation.cpp
similarity index 100%
rename from cocos/2d/sprite-nodes/CCAnimation.cpp
rename to cocos/2d/CCAnimation.cpp
diff --git a/cocos/2d/sprite-nodes/CCAnimation.h b/cocos/2d/CCAnimation.h
similarity index 100%
rename from cocos/2d/sprite-nodes/CCAnimation.h
rename to cocos/2d/CCAnimation.h
diff --git a/cocos/2d/sprite-nodes/CCAnimationCache.cpp b/cocos/2d/CCAnimationCache.cpp
similarity index 100%
rename from cocos/2d/sprite-nodes/CCAnimationCache.cpp
rename to cocos/2d/CCAnimationCache.cpp
diff --git a/cocos/2d/sprite-nodes/CCAnimationCache.h b/cocos/2d/CCAnimationCache.h
similarity index 100%
rename from cocos/2d/sprite-nodes/CCAnimationCache.h
rename to cocos/2d/CCAnimationCache.h
diff --git a/cocos/2d/base-nodes/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp
similarity index 100%
rename from cocos/2d/base-nodes/CCAtlasNode.cpp
rename to cocos/2d/CCAtlasNode.cpp
diff --git a/cocos/2d/base-nodes/CCAtlasNode.h b/cocos/2d/CCAtlasNode.h
similarity index 100%
rename from cocos/2d/base-nodes/CCAtlasNode.h
rename to cocos/2d/CCAtlasNode.h
diff --git a/cocos/2d/misc-nodes/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp
similarity index 100%
rename from cocos/2d/misc-nodes/CCClippingNode.cpp
rename to cocos/2d/CCClippingNode.cpp
diff --git a/cocos/2d/misc-nodes/CCClippingNode.h b/cocos/2d/CCClippingNode.h
similarity index 100%
rename from cocos/2d/misc-nodes/CCClippingNode.h
rename to cocos/2d/CCClippingNode.h
diff --git a/cocos/2d/support/component/CCComponent.cpp b/cocos/2d/CCComponent.cpp
similarity index 100%
rename from cocos/2d/support/component/CCComponent.cpp
rename to cocos/2d/CCComponent.cpp
diff --git a/cocos/2d/support/component/CCComponent.h b/cocos/2d/CCComponent.h
similarity index 100%
rename from cocos/2d/support/component/CCComponent.h
rename to cocos/2d/CCComponent.h
diff --git a/cocos/2d/support/component/CCComponentContainer.cpp b/cocos/2d/CCComponentContainer.cpp
similarity index 100%
rename from cocos/2d/support/component/CCComponentContainer.cpp
rename to cocos/2d/CCComponentContainer.cpp
diff --git a/cocos/2d/support/component/CCComponentContainer.h b/cocos/2d/CCComponentContainer.h
similarity index 100%
rename from cocos/2d/support/component/CCComponentContainer.h
rename to cocos/2d/CCComponentContainer.h
diff --git a/cocos/2d/include/CCDeprecated.h b/cocos/2d/CCDeprecated.h
similarity index 100%
rename from cocos/2d/include/CCDeprecated.h
rename to cocos/2d/CCDeprecated.h
diff --git a/cocos/2d/draw-nodes/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp
similarity index 100%
rename from cocos/2d/draw-nodes/CCDrawNode.cpp
rename to cocos/2d/CCDrawNode.cpp
diff --git a/cocos/2d/draw-nodes/CCDrawNode.h b/cocos/2d/CCDrawNode.h
similarity index 100%
rename from cocos/2d/draw-nodes/CCDrawNode.h
rename to cocos/2d/CCDrawNode.h
diff --git a/cocos/2d/draw-nodes/CCDrawingPrimitives.cpp b/cocos/2d/CCDrawingPrimitives.cpp
similarity index 100%
rename from cocos/2d/draw-nodes/CCDrawingPrimitives.cpp
rename to cocos/2d/CCDrawingPrimitives.cpp
diff --git a/cocos/2d/draw-nodes/CCDrawingPrimitives.h b/cocos/2d/CCDrawingPrimitives.h
similarity index 100%
rename from cocos/2d/draw-nodes/CCDrawingPrimitives.h
rename to cocos/2d/CCDrawingPrimitives.h
diff --git a/cocos/2d/event-dispatcher/CCEvent.cpp b/cocos/2d/CCEvent.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEvent.cpp
rename to cocos/2d/CCEvent.cpp
diff --git a/cocos/2d/event-dispatcher/CCEvent.h b/cocos/2d/CCEvent.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEvent.h
rename to cocos/2d/CCEvent.h
diff --git a/cocos/2d/event-dispatcher/CCEventAcceleration.cpp b/cocos/2d/CCEventAcceleration.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventAcceleration.cpp
rename to cocos/2d/CCEventAcceleration.cpp
diff --git a/cocos/2d/event-dispatcher/CCEventAcceleration.h b/cocos/2d/CCEventAcceleration.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventAcceleration.h
rename to cocos/2d/CCEventAcceleration.h
diff --git a/cocos/2d/event-dispatcher/CCEventCustom.cpp b/cocos/2d/CCEventCustom.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventCustom.cpp
rename to cocos/2d/CCEventCustom.cpp
diff --git a/cocos/2d/event-dispatcher/CCEventCustom.h b/cocos/2d/CCEventCustom.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventCustom.h
rename to cocos/2d/CCEventCustom.h
diff --git a/cocos/2d/event-dispatcher/CCEventDispatcher.cpp b/cocos/2d/CCEventDispatcher.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventDispatcher.cpp
rename to cocos/2d/CCEventDispatcher.cpp
diff --git a/cocos/2d/event-dispatcher/CCEventDispatcher.h b/cocos/2d/CCEventDispatcher.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventDispatcher.h
rename to cocos/2d/CCEventDispatcher.h
diff --git a/cocos/2d/event-dispatcher/CCEventKeyboard.cpp b/cocos/2d/CCEventKeyboard.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventKeyboard.cpp
rename to cocos/2d/CCEventKeyboard.cpp
diff --git a/cocos/2d/event-dispatcher/CCEventKeyboard.h b/cocos/2d/CCEventKeyboard.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventKeyboard.h
rename to cocos/2d/CCEventKeyboard.h
diff --git a/cocos/2d/event-dispatcher/CCEventListener.cpp b/cocos/2d/CCEventListener.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventListener.cpp
rename to cocos/2d/CCEventListener.cpp
diff --git a/cocos/2d/event-dispatcher/CCEventListener.h b/cocos/2d/CCEventListener.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventListener.h
rename to cocos/2d/CCEventListener.h
diff --git a/cocos/2d/event-dispatcher/CCEventListenerAcceleration.cpp b/cocos/2d/CCEventListenerAcceleration.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventListenerAcceleration.cpp
rename to cocos/2d/CCEventListenerAcceleration.cpp
diff --git a/cocos/2d/event-dispatcher/CCEventListenerAcceleration.h b/cocos/2d/CCEventListenerAcceleration.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventListenerAcceleration.h
rename to cocos/2d/CCEventListenerAcceleration.h
diff --git a/cocos/2d/event-dispatcher/CCEventListenerCustom.cpp b/cocos/2d/CCEventListenerCustom.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventListenerCustom.cpp
rename to cocos/2d/CCEventListenerCustom.cpp
diff --git a/cocos/2d/event-dispatcher/CCEventListenerCustom.h b/cocos/2d/CCEventListenerCustom.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventListenerCustom.h
rename to cocos/2d/CCEventListenerCustom.h
diff --git a/cocos/2d/event-dispatcher/CCEventListenerKeyboard.cpp b/cocos/2d/CCEventListenerKeyboard.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventListenerKeyboard.cpp
rename to cocos/2d/CCEventListenerKeyboard.cpp
diff --git a/cocos/2d/event-dispatcher/CCEventListenerKeyboard.h b/cocos/2d/CCEventListenerKeyboard.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventListenerKeyboard.h
rename to cocos/2d/CCEventListenerKeyboard.h
diff --git a/cocos/2d/event-dispatcher/CCEventListenerTouch.cpp b/cocos/2d/CCEventListenerTouch.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventListenerTouch.cpp
rename to cocos/2d/CCEventListenerTouch.cpp
diff --git a/cocos/2d/event-dispatcher/CCEventListenerTouch.h b/cocos/2d/CCEventListenerTouch.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventListenerTouch.h
rename to cocos/2d/CCEventListenerTouch.h
diff --git a/cocos/2d/event-dispatcher/CCEventTouch.cpp b/cocos/2d/CCEventTouch.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventTouch.cpp
rename to cocos/2d/CCEventTouch.cpp
diff --git a/cocos/2d/event-dispatcher/CCEventTouch.h b/cocos/2d/CCEventTouch.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCEventTouch.h
rename to cocos/2d/CCEventTouch.h
diff --git a/cocos/2d/include/CCEventType.h b/cocos/2d/CCEventType.h
similarity index 100%
rename from cocos/2d/include/CCEventType.h
rename to cocos/2d/CCEventType.h
diff --git a/cocos/2d/label-nodes/CCFont.cpp b/cocos/2d/CCFont.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCFont.cpp
rename to cocos/2d/CCFont.cpp
diff --git a/cocos/2d/label-nodes/CCFont.h b/cocos/2d/CCFont.h
similarity index 100%
rename from cocos/2d/label-nodes/CCFont.h
rename to cocos/2d/CCFont.h
diff --git a/cocos/2d/label-nodes/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCFontAtlas.cpp
rename to cocos/2d/CCFontAtlas.cpp
diff --git a/cocos/2d/label-nodes/CCFontAtlas.h b/cocos/2d/CCFontAtlas.h
similarity index 100%
rename from cocos/2d/label-nodes/CCFontAtlas.h
rename to cocos/2d/CCFontAtlas.h
diff --git a/cocos/2d/label-nodes/CCFontAtlasCache.cpp b/cocos/2d/CCFontAtlasCache.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCFontAtlasCache.cpp
rename to cocos/2d/CCFontAtlasCache.cpp
diff --git a/cocos/2d/label-nodes/CCFontAtlasCache.h b/cocos/2d/CCFontAtlasCache.h
similarity index 100%
rename from cocos/2d/label-nodes/CCFontAtlasCache.h
rename to cocos/2d/CCFontAtlasCache.h
diff --git a/cocos/2d/label-nodes/CCFontAtlasFactory.cpp b/cocos/2d/CCFontAtlasFactory.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCFontAtlasFactory.cpp
rename to cocos/2d/CCFontAtlasFactory.cpp
diff --git a/cocos/2d/label-nodes/CCFontAtlasFactory.h b/cocos/2d/CCFontAtlasFactory.h
similarity index 100%
rename from cocos/2d/label-nodes/CCFontAtlasFactory.h
rename to cocos/2d/CCFontAtlasFactory.h
diff --git a/cocos/2d/label-nodes/CCFontDefinition.cpp b/cocos/2d/CCFontDefinition.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCFontDefinition.cpp
rename to cocos/2d/CCFontDefinition.cpp
diff --git a/cocos/2d/label-nodes/CCFontDefinition.h b/cocos/2d/CCFontDefinition.h
similarity index 100%
rename from cocos/2d/label-nodes/CCFontDefinition.h
rename to cocos/2d/CCFontDefinition.h
diff --git a/cocos/2d/label-nodes/CCFontFNT.cpp b/cocos/2d/CCFontFNT.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCFontFNT.cpp
rename to cocos/2d/CCFontFNT.cpp
diff --git a/cocos/2d/label-nodes/CCFontFNT.h b/cocos/2d/CCFontFNT.h
similarity index 100%
rename from cocos/2d/label-nodes/CCFontFNT.h
rename to cocos/2d/CCFontFNT.h
diff --git a/cocos/2d/label-nodes/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCFontFreeType.cpp
rename to cocos/2d/CCFontFreeType.cpp
diff --git a/cocos/2d/label-nodes/CCFontFreeType.h b/cocos/2d/CCFontFreeType.h
similarity index 100%
rename from cocos/2d/label-nodes/CCFontFreeType.h
rename to cocos/2d/CCFontFreeType.h
diff --git a/cocos/2d/base-nodes/CCGLBufferedNode.cpp b/cocos/2d/CCGLBufferedNode.cpp
similarity index 100%
rename from cocos/2d/base-nodes/CCGLBufferedNode.cpp
rename to cocos/2d/CCGLBufferedNode.cpp
diff --git a/cocos/2d/base-nodes/CCGLBufferedNode.h b/cocos/2d/CCGLBufferedNode.h
similarity index 100%
rename from cocos/2d/base-nodes/CCGLBufferedNode.h
rename to cocos/2d/CCGLBufferedNode.h
diff --git a/cocos/2d/shaders/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp
similarity index 100%
rename from cocos/2d/shaders/CCGLProgram.cpp
rename to cocos/2d/CCGLProgram.cpp
diff --git a/cocos/2d/shaders/CCGLProgram.h b/cocos/2d/CCGLProgram.h
similarity index 100%
rename from cocos/2d/shaders/CCGLProgram.h
rename to cocos/2d/CCGLProgram.h
diff --git a/cocos/2d/effects/CCGrabber.cpp b/cocos/2d/CCGrabber.cpp
similarity index 100%
rename from cocos/2d/effects/CCGrabber.cpp
rename to cocos/2d/CCGrabber.cpp
diff --git a/cocos/2d/effects/CCGrabber.h b/cocos/2d/CCGrabber.h
similarity index 100%
rename from cocos/2d/effects/CCGrabber.h
rename to cocos/2d/CCGrabber.h
diff --git a/cocos/2d/effects/CCGrid.cpp b/cocos/2d/CCGrid.cpp
similarity index 100%
rename from cocos/2d/effects/CCGrid.cpp
rename to cocos/2d/CCGrid.cpp
diff --git a/cocos/2d/effects/CCGrid.h b/cocos/2d/CCGrid.h
similarity index 100%
rename from cocos/2d/effects/CCGrid.h
rename to cocos/2d/CCGrid.h
diff --git a/cocos/2d/text-input-node/CCIMEDelegate.h b/cocos/2d/CCIMEDelegate.h
similarity index 100%
rename from cocos/2d/text-input-node/CCIMEDelegate.h
rename to cocos/2d/CCIMEDelegate.h
diff --git a/cocos/2d/text-input-node/CCIMEDispatcher.cpp b/cocos/2d/CCIMEDispatcher.cpp
similarity index 100%
rename from cocos/2d/text-input-node/CCIMEDispatcher.cpp
rename to cocos/2d/CCIMEDispatcher.cpp
diff --git a/cocos/2d/text-input-node/CCIMEDispatcher.h b/cocos/2d/CCIMEDispatcher.h
similarity index 100%
rename from cocos/2d/text-input-node/CCIMEDispatcher.h
rename to cocos/2d/CCIMEDispatcher.h
diff --git a/cocos/2d/label-nodes/CCLabel.cpp b/cocos/2d/CCLabel.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCLabel.cpp
rename to cocos/2d/CCLabel.cpp
diff --git a/cocos/2d/label-nodes/CCLabel.h b/cocos/2d/CCLabel.h
similarity index 100%
rename from cocos/2d/label-nodes/CCLabel.h
rename to cocos/2d/CCLabel.h
diff --git a/cocos/2d/label-nodes/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCLabelAtlas.cpp
rename to cocos/2d/CCLabelAtlas.cpp
diff --git a/cocos/2d/label-nodes/CCLabelAtlas.h b/cocos/2d/CCLabelAtlas.h
similarity index 100%
rename from cocos/2d/label-nodes/CCLabelAtlas.h
rename to cocos/2d/CCLabelAtlas.h
diff --git a/cocos/2d/label-nodes/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCLabelBMFont.cpp
rename to cocos/2d/CCLabelBMFont.cpp
diff --git a/cocos/2d/label-nodes/CCLabelBMFont.h b/cocos/2d/CCLabelBMFont.h
similarity index 100%
rename from cocos/2d/label-nodes/CCLabelBMFont.h
rename to cocos/2d/CCLabelBMFont.h
diff --git a/cocos/2d/label-nodes/CCLabelTTF.cpp b/cocos/2d/CCLabelTTF.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCLabelTTF.cpp
rename to cocos/2d/CCLabelTTF.cpp
diff --git a/cocos/2d/label-nodes/CCLabelTTF.h b/cocos/2d/CCLabelTTF.h
similarity index 100%
rename from cocos/2d/label-nodes/CCLabelTTF.h
rename to cocos/2d/CCLabelTTF.h
diff --git a/cocos/2d/label-nodes/CCLabelTextFormatProtocol.h b/cocos/2d/CCLabelTextFormatProtocol.h
similarity index 100%
rename from cocos/2d/label-nodes/CCLabelTextFormatProtocol.h
rename to cocos/2d/CCLabelTextFormatProtocol.h
diff --git a/cocos/2d/label-nodes/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCLabelTextFormatter.cpp
rename to cocos/2d/CCLabelTextFormatter.cpp
diff --git a/cocos/2d/label-nodes/CCLabelTextFormatter.h b/cocos/2d/CCLabelTextFormatter.h
similarity index 100%
rename from cocos/2d/label-nodes/CCLabelTextFormatter.h
rename to cocos/2d/CCLabelTextFormatter.h
diff --git a/cocos/2d/layers-scenes-transitions-nodes/CCLayer.cpp b/cocos/2d/CCLayer.cpp
similarity index 100%
rename from cocos/2d/layers-scenes-transitions-nodes/CCLayer.cpp
rename to cocos/2d/CCLayer.cpp
diff --git a/cocos/2d/layers-scenes-transitions-nodes/CCLayer.h b/cocos/2d/CCLayer.h
similarity index 100%
rename from cocos/2d/layers-scenes-transitions-nodes/CCLayer.h
rename to cocos/2d/CCLayer.h
diff --git a/cocos/2d/menu-nodes/CCMenu.cpp b/cocos/2d/CCMenu.cpp
similarity index 100%
rename from cocos/2d/menu-nodes/CCMenu.cpp
rename to cocos/2d/CCMenu.cpp
diff --git a/cocos/2d/menu-nodes/CCMenu.h b/cocos/2d/CCMenu.h
similarity index 100%
rename from cocos/2d/menu-nodes/CCMenu.h
rename to cocos/2d/CCMenu.h
diff --git a/cocos/2d/menu-nodes/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp
similarity index 100%
rename from cocos/2d/menu-nodes/CCMenuItem.cpp
rename to cocos/2d/CCMenuItem.cpp
diff --git a/cocos/2d/menu-nodes/CCMenuItem.h b/cocos/2d/CCMenuItem.h
similarity index 100%
rename from cocos/2d/menu-nodes/CCMenuItem.h
rename to cocos/2d/CCMenuItem.h
diff --git a/cocos/2d/misc-nodes/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp
similarity index 100%
rename from cocos/2d/misc-nodes/CCMotionStreak.cpp
rename to cocos/2d/CCMotionStreak.cpp
diff --git a/cocos/2d/misc-nodes/CCMotionStreak.h b/cocos/2d/CCMotionStreak.h
similarity index 100%
rename from cocos/2d/misc-nodes/CCMotionStreak.h
rename to cocos/2d/CCMotionStreak.h
diff --git a/cocos/2d/base-nodes/CCNode.cpp b/cocos/2d/CCNode.cpp
similarity index 100%
rename from cocos/2d/base-nodes/CCNode.cpp
rename to cocos/2d/CCNode.cpp
diff --git a/cocos/2d/base-nodes/CCNode.h b/cocos/2d/CCNode.h
similarity index 100%
rename from cocos/2d/base-nodes/CCNode.h
rename to cocos/2d/CCNode.h
diff --git a/cocos/2d/support/CCNotificationCenter.cpp b/cocos/2d/CCNotificationCenter.cpp
similarity index 100%
rename from cocos/2d/support/CCNotificationCenter.cpp
rename to cocos/2d/CCNotificationCenter.cpp
diff --git a/cocos/2d/support/CCNotificationCenter.h b/cocos/2d/CCNotificationCenter.h
similarity index 100%
rename from cocos/2d/support/CCNotificationCenter.h
rename to cocos/2d/CCNotificationCenter.h
diff --git a/cocos/2d/tilemap-parallax-nodes/CCParallaxNode.cpp b/cocos/2d/CCParallaxNode.cpp
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCParallaxNode.cpp
rename to cocos/2d/CCParallaxNode.cpp
diff --git a/cocos/2d/tilemap-parallax-nodes/CCParallaxNode.h b/cocos/2d/CCParallaxNode.h
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCParallaxNode.h
rename to cocos/2d/CCParallaxNode.h
diff --git a/cocos/2d/particle-nodes/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp
similarity index 100%
rename from cocos/2d/particle-nodes/CCParticleBatchNode.cpp
rename to cocos/2d/CCParticleBatchNode.cpp
diff --git a/cocos/2d/particle-nodes/CCParticleBatchNode.h b/cocos/2d/CCParticleBatchNode.h
similarity index 100%
rename from cocos/2d/particle-nodes/CCParticleBatchNode.h
rename to cocos/2d/CCParticleBatchNode.h
diff --git a/cocos/2d/particle-nodes/CCParticleExamples.cpp b/cocos/2d/CCParticleExamples.cpp
similarity index 100%
rename from cocos/2d/particle-nodes/CCParticleExamples.cpp
rename to cocos/2d/CCParticleExamples.cpp
diff --git a/cocos/2d/particle-nodes/CCParticleExamples.h b/cocos/2d/CCParticleExamples.h
similarity index 100%
rename from cocos/2d/particle-nodes/CCParticleExamples.h
rename to cocos/2d/CCParticleExamples.h
diff --git a/cocos/2d/particle-nodes/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp
similarity index 100%
rename from cocos/2d/particle-nodes/CCParticleSystem.cpp
rename to cocos/2d/CCParticleSystem.cpp
diff --git a/cocos/2d/particle-nodes/CCParticleSystem.h b/cocos/2d/CCParticleSystem.h
similarity index 100%
rename from cocos/2d/particle-nodes/CCParticleSystem.h
rename to cocos/2d/CCParticleSystem.h
diff --git a/cocos/2d/particle-nodes/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp
similarity index 100%
rename from cocos/2d/particle-nodes/CCParticleSystemQuad.cpp
rename to cocos/2d/CCParticleSystemQuad.cpp
diff --git a/cocos/2d/particle-nodes/CCParticleSystemQuad.h b/cocos/2d/CCParticleSystemQuad.h
similarity index 100%
rename from cocos/2d/particle-nodes/CCParticleSystemQuad.h
rename to cocos/2d/CCParticleSystemQuad.h
diff --git a/cocos/2d/support/CCProfiling.cpp b/cocos/2d/CCProfiling.cpp
similarity index 100%
rename from cocos/2d/support/CCProfiling.cpp
rename to cocos/2d/CCProfiling.cpp
diff --git a/cocos/2d/support/CCProfiling.h b/cocos/2d/CCProfiling.h
similarity index 100%
rename from cocos/2d/support/CCProfiling.h
rename to cocos/2d/CCProfiling.h
diff --git a/cocos/2d/misc-nodes/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp
similarity index 100%
rename from cocos/2d/misc-nodes/CCProgressTimer.cpp
rename to cocos/2d/CCProgressTimer.cpp
diff --git a/cocos/2d/misc-nodes/CCProgressTimer.h b/cocos/2d/CCProgressTimer.h
similarity index 100%
rename from cocos/2d/misc-nodes/CCProgressTimer.h
rename to cocos/2d/CCProgressTimer.h
diff --git a/cocos/2d/include/CCProtocols.h b/cocos/2d/CCProtocols.h
similarity index 100%
rename from cocos/2d/include/CCProtocols.h
rename to cocos/2d/CCProtocols.h
diff --git a/cocos/2d/misc-nodes/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp
similarity index 100%
rename from cocos/2d/misc-nodes/CCRenderTexture.cpp
rename to cocos/2d/CCRenderTexture.cpp
diff --git a/cocos/2d/misc-nodes/CCRenderTexture.h b/cocos/2d/CCRenderTexture.h
similarity index 100%
rename from cocos/2d/misc-nodes/CCRenderTexture.h
rename to cocos/2d/CCRenderTexture.h
diff --git a/cocos/2d/layers-scenes-transitions-nodes/CCScene.cpp b/cocos/2d/CCScene.cpp
similarity index 100%
rename from cocos/2d/layers-scenes-transitions-nodes/CCScene.cpp
rename to cocos/2d/CCScene.cpp
diff --git a/cocos/2d/layers-scenes-transitions-nodes/CCScene.h b/cocos/2d/CCScene.h
similarity index 100%
rename from cocos/2d/layers-scenes-transitions-nodes/CCScene.h
rename to cocos/2d/CCScene.h
diff --git a/cocos/2d/script-support/CCScriptSupport.cpp b/cocos/2d/CCScriptSupport.cpp
similarity index 100%
rename from cocos/2d/script-support/CCScriptSupport.cpp
rename to cocos/2d/CCScriptSupport.cpp
diff --git a/cocos/2d/script-support/CCScriptSupport.h b/cocos/2d/CCScriptSupport.h
similarity index 100%
rename from cocos/2d/script-support/CCScriptSupport.h
rename to cocos/2d/CCScriptSupport.h
diff --git a/cocos/2d/shaders/CCShaderCache.cpp b/cocos/2d/CCShaderCache.cpp
similarity index 100%
rename from cocos/2d/shaders/CCShaderCache.cpp
rename to cocos/2d/CCShaderCache.cpp
diff --git a/cocos/2d/shaders/CCShaderCache.h b/cocos/2d/CCShaderCache.h
similarity index 100%
rename from cocos/2d/shaders/CCShaderCache.h
rename to cocos/2d/CCShaderCache.h
diff --git a/cocos/2d/sprite-nodes/CCSprite.cpp b/cocos/2d/CCSprite.cpp
similarity index 100%
rename from cocos/2d/sprite-nodes/CCSprite.cpp
rename to cocos/2d/CCSprite.cpp
diff --git a/cocos/2d/sprite-nodes/CCSprite.h b/cocos/2d/CCSprite.h
similarity index 100%
rename from cocos/2d/sprite-nodes/CCSprite.h
rename to cocos/2d/CCSprite.h
diff --git a/cocos/2d/sprite-nodes/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp
similarity index 100%
rename from cocos/2d/sprite-nodes/CCSpriteBatchNode.cpp
rename to cocos/2d/CCSpriteBatchNode.cpp
diff --git a/cocos/2d/sprite-nodes/CCSpriteBatchNode.h b/cocos/2d/CCSpriteBatchNode.h
similarity index 100%
rename from cocos/2d/sprite-nodes/CCSpriteBatchNode.h
rename to cocos/2d/CCSpriteBatchNode.h
diff --git a/cocos/2d/sprite-nodes/CCSpriteFrame.cpp b/cocos/2d/CCSpriteFrame.cpp
similarity index 100%
rename from cocos/2d/sprite-nodes/CCSpriteFrame.cpp
rename to cocos/2d/CCSpriteFrame.cpp
diff --git a/cocos/2d/sprite-nodes/CCSpriteFrame.h b/cocos/2d/CCSpriteFrame.h
similarity index 100%
rename from cocos/2d/sprite-nodes/CCSpriteFrame.h
rename to cocos/2d/CCSpriteFrame.h
diff --git a/cocos/2d/sprite-nodes/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp
similarity index 100%
rename from cocos/2d/sprite-nodes/CCSpriteFrameCache.cpp
rename to cocos/2d/CCSpriteFrameCache.cpp
diff --git a/cocos/2d/sprite-nodes/CCSpriteFrameCache.h b/cocos/2d/CCSpriteFrameCache.h
similarity index 100%
rename from cocos/2d/sprite-nodes/CCSpriteFrameCache.h
rename to cocos/2d/CCSpriteFrameCache.h
diff --git a/cocos/2d/tilemap-parallax-nodes/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCTMXLayer.cpp
rename to cocos/2d/CCTMXLayer.cpp
diff --git a/cocos/2d/tilemap-parallax-nodes/CCTMXLayer.h b/cocos/2d/CCTMXLayer.h
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCTMXLayer.h
rename to cocos/2d/CCTMXLayer.h
diff --git a/cocos/2d/tilemap-parallax-nodes/CCTMXObjectGroup.cpp b/cocos/2d/CCTMXObjectGroup.cpp
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCTMXObjectGroup.cpp
rename to cocos/2d/CCTMXObjectGroup.cpp
diff --git a/cocos/2d/tilemap-parallax-nodes/CCTMXObjectGroup.h b/cocos/2d/CCTMXObjectGroup.h
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCTMXObjectGroup.h
rename to cocos/2d/CCTMXObjectGroup.h
diff --git a/cocos/2d/tilemap-parallax-nodes/CCTMXTiledMap.cpp b/cocos/2d/CCTMXTiledMap.cpp
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCTMXTiledMap.cpp
rename to cocos/2d/CCTMXTiledMap.cpp
diff --git a/cocos/2d/tilemap-parallax-nodes/CCTMXTiledMap.h b/cocos/2d/CCTMXTiledMap.h
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCTMXTiledMap.h
rename to cocos/2d/CCTMXTiledMap.h
diff --git a/cocos/2d/tilemap-parallax-nodes/CCTMXXMLParser.cpp b/cocos/2d/CCTMXXMLParser.cpp
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCTMXXMLParser.cpp
rename to cocos/2d/CCTMXXMLParser.cpp
diff --git a/cocos/2d/tilemap-parallax-nodes/CCTMXXMLParser.h b/cocos/2d/CCTMXXMLParser.h
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCTMXXMLParser.h
rename to cocos/2d/CCTMXXMLParser.h
diff --git a/cocos/2d/text-input-node/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp
similarity index 100%
rename from cocos/2d/text-input-node/CCTextFieldTTF.cpp
rename to cocos/2d/CCTextFieldTTF.cpp
diff --git a/cocos/2d/text-input-node/CCTextFieldTTF.h b/cocos/2d/CCTextFieldTTF.h
similarity index 100%
rename from cocos/2d/text-input-node/CCTextFieldTTF.h
rename to cocos/2d/CCTextFieldTTF.h
diff --git a/cocos/2d/label-nodes/CCTextImage.cpp b/cocos/2d/CCTextImage.cpp
similarity index 100%
rename from cocos/2d/label-nodes/CCTextImage.cpp
rename to cocos/2d/CCTextImage.cpp
diff --git a/cocos/2d/label-nodes/CCTextImage.h b/cocos/2d/CCTextImage.h
similarity index 100%
rename from cocos/2d/label-nodes/CCTextImage.h
rename to cocos/2d/CCTextImage.h
diff --git a/cocos/2d/textures/CCTexture2D.cpp b/cocos/2d/CCTexture2D.cpp
similarity index 100%
rename from cocos/2d/textures/CCTexture2D.cpp
rename to cocos/2d/CCTexture2D.cpp
diff --git a/cocos/2d/textures/CCTexture2D.h b/cocos/2d/CCTexture2D.h
similarity index 100%
rename from cocos/2d/textures/CCTexture2D.h
rename to cocos/2d/CCTexture2D.h
diff --git a/cocos/2d/textures/CCTextureAtlas.cpp b/cocos/2d/CCTextureAtlas.cpp
similarity index 100%
rename from cocos/2d/textures/CCTextureAtlas.cpp
rename to cocos/2d/CCTextureAtlas.cpp
diff --git a/cocos/2d/textures/CCTextureAtlas.h b/cocos/2d/CCTextureAtlas.h
similarity index 100%
rename from cocos/2d/textures/CCTextureAtlas.h
rename to cocos/2d/CCTextureAtlas.h
diff --git a/cocos/2d/textures/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp
similarity index 100%
rename from cocos/2d/textures/CCTextureCache.cpp
rename to cocos/2d/CCTextureCache.cpp
diff --git a/cocos/2d/textures/CCTextureCache.h b/cocos/2d/CCTextureCache.h
similarity index 100%
rename from cocos/2d/textures/CCTextureCache.h
rename to cocos/2d/CCTextureCache.h
diff --git a/cocos/2d/tilemap-parallax-nodes/CCTileMapAtlas.cpp b/cocos/2d/CCTileMapAtlas.cpp
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCTileMapAtlas.cpp
rename to cocos/2d/CCTileMapAtlas.cpp
diff --git a/cocos/2d/tilemap-parallax-nodes/CCTileMapAtlas.h b/cocos/2d/CCTileMapAtlas.h
similarity index 100%
rename from cocos/2d/tilemap-parallax-nodes/CCTileMapAtlas.h
rename to cocos/2d/CCTileMapAtlas.h
diff --git a/cocos/2d/event-dispatcher/CCTouch.cpp b/cocos/2d/CCTouch.cpp
similarity index 100%
rename from cocos/2d/event-dispatcher/CCTouch.cpp
rename to cocos/2d/CCTouch.cpp
diff --git a/cocos/2d/event-dispatcher/CCTouch.h b/cocos/2d/CCTouch.h
similarity index 100%
rename from cocos/2d/event-dispatcher/CCTouch.h
rename to cocos/2d/CCTouch.h
diff --git a/cocos/2d/layers-scenes-transitions-nodes/CCTransition.cpp b/cocos/2d/CCTransition.cpp
similarity index 100%
rename from cocos/2d/layers-scenes-transitions-nodes/CCTransition.cpp
rename to cocos/2d/CCTransition.cpp
diff --git a/cocos/2d/layers-scenes-transitions-nodes/CCTransition.h b/cocos/2d/CCTransition.h
similarity index 100%
rename from cocos/2d/layers-scenes-transitions-nodes/CCTransition.h
rename to cocos/2d/CCTransition.h
diff --git a/cocos/2d/layers-scenes-transitions-nodes/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp
similarity index 100%
rename from cocos/2d/layers-scenes-transitions-nodes/CCTransitionPageTurn.cpp
rename to cocos/2d/CCTransitionPageTurn.cpp
diff --git a/cocos/2d/layers-scenes-transitions-nodes/CCTransitionPageTurn.h b/cocos/2d/CCTransitionPageTurn.h
similarity index 100%
rename from cocos/2d/layers-scenes-transitions-nodes/CCTransitionPageTurn.h
rename to cocos/2d/CCTransitionPageTurn.h
diff --git a/cocos/2d/layers-scenes-transitions-nodes/CCTransitionProgress.cpp b/cocos/2d/CCTransitionProgress.cpp
similarity index 100%
rename from cocos/2d/layers-scenes-transitions-nodes/CCTransitionProgress.cpp
rename to cocos/2d/CCTransitionProgress.cpp
diff --git a/cocos/2d/layers-scenes-transitions-nodes/CCTransitionProgress.h b/cocos/2d/CCTransitionProgress.h
similarity index 100%
rename from cocos/2d/layers-scenes-transitions-nodes/CCTransitionProgress.h
rename to cocos/2d/CCTransitionProgress.h
diff --git a/cocos/2d/support/user_default/CCUserDefault.cpp b/cocos/2d/CCUserDefault.cpp
similarity index 100%
rename from cocos/2d/support/user_default/CCUserDefault.cpp
rename to cocos/2d/CCUserDefault.cpp
diff --git a/cocos/2d/support/user_default/CCUserDefault.h b/cocos/2d/CCUserDefault.h
similarity index 100%
rename from cocos/2d/support/user_default/CCUserDefault.h
rename to cocos/2d/CCUserDefault.h
diff --git a/cocos/2d/support/user_default/CCUserDefault.mm b/cocos/2d/CCUserDefault.mm
similarity index 100%
rename from cocos/2d/support/user_default/CCUserDefault.mm
rename to cocos/2d/CCUserDefault.mm
diff --git a/cocos/2d/support/user_default/CCUserDefaultAndroid.cpp b/cocos/2d/CCUserDefaultAndroid.cpp
similarity index 100%
rename from cocos/2d/support/user_default/CCUserDefaultAndroid.cpp
rename to cocos/2d/CCUserDefaultAndroid.cpp
diff --git a/cocos/2d/support/CCVertex.cpp b/cocos/2d/CCVertex.cpp
similarity index 100%
rename from cocos/2d/support/CCVertex.cpp
rename to cocos/2d/CCVertex.cpp
diff --git a/cocos/2d/support/CCVertex.h b/cocos/2d/CCVertex.h
similarity index 100%
rename from cocos/2d/support/CCVertex.h
rename to cocos/2d/CCVertex.h
diff --git a/cocos/2d/proj.linux/Makefile b/cocos/2d/Makefile
similarity index 100%
rename from cocos/2d/proj.linux/Makefile
rename to cocos/2d/Makefile
diff --git a/cocos/2d/support/image_support/TGAlib.cpp b/cocos/2d/TGAlib.cpp
similarity index 100%
rename from cocos/2d/support/image_support/TGAlib.cpp
rename to cocos/2d/TGAlib.cpp
diff --git a/cocos/2d/support/image_support/TGAlib.h b/cocos/2d/TGAlib.h
similarity index 100%
rename from cocos/2d/support/image_support/TGAlib.h
rename to cocos/2d/TGAlib.h
diff --git a/cocos/2d/support/TransformUtils.cpp b/cocos/2d/TransformUtils.cpp
similarity index 100%
rename from cocos/2d/support/TransformUtils.cpp
rename to cocos/2d/TransformUtils.cpp
diff --git a/cocos/2d/support/TransformUtils.h b/cocos/2d/TransformUtils.h
similarity index 100%
rename from cocos/2d/support/TransformUtils.h
rename to cocos/2d/TransformUtils.h
diff --git a/cocos/2d/support/zip_support/ZipUtils.cpp b/cocos/2d/ZipUtils.cpp
similarity index 100%
rename from cocos/2d/support/zip_support/ZipUtils.cpp
rename to cocos/2d/ZipUtils.cpp
diff --git a/cocos/2d/support/zip_support/ZipUtils.h b/cocos/2d/ZipUtils.h
similarity index 100%
rename from cocos/2d/support/zip_support/ZipUtils.h
rename to cocos/2d/ZipUtils.h
diff --git a/cocos/2d/support/base64.cpp b/cocos/2d/base64.cpp
similarity index 100%
rename from cocos/2d/support/base64.cpp
rename to cocos/2d/base64.cpp
diff --git a/cocos/2d/support/base64.h b/cocos/2d/base64.h
similarity index 100%
rename from cocos/2d/support/base64.h
rename to cocos/2d/base64.h
diff --git a/cocos/2d/support/data_support/ccCArray.cpp b/cocos/2d/ccCArray.cpp
similarity index 100%
rename from cocos/2d/support/data_support/ccCArray.cpp
rename to cocos/2d/ccCArray.cpp
diff --git a/cocos/2d/support/data_support/ccCArray.h b/cocos/2d/ccCArray.h
similarity index 100%
rename from cocos/2d/support/data_support/ccCArray.h
rename to cocos/2d/ccCArray.h
diff --git a/cocos/2d/include/ccConfig.h b/cocos/2d/ccConfig.h
similarity index 100%
rename from cocos/2d/include/ccConfig.h
rename to cocos/2d/ccConfig.h
diff --git a/cocos/2d/shaders/ccGLStateCache.cpp b/cocos/2d/ccGLStateCache.cpp
similarity index 100%
rename from cocos/2d/shaders/ccGLStateCache.cpp
rename to cocos/2d/ccGLStateCache.cpp
diff --git a/cocos/2d/shaders/ccGLStateCache.h b/cocos/2d/ccGLStateCache.h
similarity index 100%
rename from cocos/2d/shaders/ccGLStateCache.h
rename to cocos/2d/ccGLStateCache.h
diff --git a/cocos/2d/include/ccMacros.h b/cocos/2d/ccMacros.h
similarity index 100%
rename from cocos/2d/include/ccMacros.h
rename to cocos/2d/ccMacros.h
diff --git a/cocos/2d/shaders/ccShaderEx_SwitchMask_frag.h b/cocos/2d/ccShaderEx_SwitchMask_frag.h
similarity index 100%
rename from cocos/2d/shaders/ccShaderEx_SwitchMask_frag.h
rename to cocos/2d/ccShaderEx_SwitchMask_frag.h
diff --git a/cocos/2d/shaders/ccShader_PositionColorLengthTexture_frag.h b/cocos/2d/ccShader_PositionColorLengthTexture_frag.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionColorLengthTexture_frag.h
rename to cocos/2d/ccShader_PositionColorLengthTexture_frag.h
diff --git a/cocos/2d/shaders/ccShader_PositionColorLengthTexture_vert.h b/cocos/2d/ccShader_PositionColorLengthTexture_vert.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionColorLengthTexture_vert.h
rename to cocos/2d/ccShader_PositionColorLengthTexture_vert.h
diff --git a/cocos/2d/shaders/ccShader_PositionColor_frag.h b/cocos/2d/ccShader_PositionColor_frag.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionColor_frag.h
rename to cocos/2d/ccShader_PositionColor_frag.h
diff --git a/cocos/2d/shaders/ccShader_PositionColor_vert.h b/cocos/2d/ccShader_PositionColor_vert.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionColor_vert.h
rename to cocos/2d/ccShader_PositionColor_vert.h
diff --git a/cocos/2d/shaders/ccShader_PositionTextureA8Color_frag.h b/cocos/2d/ccShader_PositionTextureA8Color_frag.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionTextureA8Color_frag.h
rename to cocos/2d/ccShader_PositionTextureA8Color_frag.h
diff --git a/cocos/2d/shaders/ccShader_PositionTextureA8Color_vert.h b/cocos/2d/ccShader_PositionTextureA8Color_vert.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionTextureA8Color_vert.h
rename to cocos/2d/ccShader_PositionTextureA8Color_vert.h
diff --git a/cocos/2d/shaders/ccShader_PositionTextureColorAlphaTest_frag.h b/cocos/2d/ccShader_PositionTextureColorAlphaTest_frag.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionTextureColorAlphaTest_frag.h
rename to cocos/2d/ccShader_PositionTextureColorAlphaTest_frag.h
diff --git a/cocos/2d/shaders/ccShader_PositionTextureColor_frag.h b/cocos/2d/ccShader_PositionTextureColor_frag.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionTextureColor_frag.h
rename to cocos/2d/ccShader_PositionTextureColor_frag.h
diff --git a/cocos/2d/shaders/ccShader_PositionTextureColor_vert.h b/cocos/2d/ccShader_PositionTextureColor_vert.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionTextureColor_vert.h
rename to cocos/2d/ccShader_PositionTextureColor_vert.h
diff --git a/cocos/2d/shaders/ccShader_PositionTexture_frag.h b/cocos/2d/ccShader_PositionTexture_frag.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionTexture_frag.h
rename to cocos/2d/ccShader_PositionTexture_frag.h
diff --git a/cocos/2d/shaders/ccShader_PositionTexture_uColor_frag.h b/cocos/2d/ccShader_PositionTexture_uColor_frag.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionTexture_uColor_frag.h
rename to cocos/2d/ccShader_PositionTexture_uColor_frag.h
diff --git a/cocos/2d/shaders/ccShader_PositionTexture_uColor_vert.h b/cocos/2d/ccShader_PositionTexture_uColor_vert.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionTexture_uColor_vert.h
rename to cocos/2d/ccShader_PositionTexture_uColor_vert.h
diff --git a/cocos/2d/shaders/ccShader_PositionTexture_vert.h b/cocos/2d/ccShader_PositionTexture_vert.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_PositionTexture_vert.h
rename to cocos/2d/ccShader_PositionTexture_vert.h
diff --git a/cocos/2d/shaders/ccShader_Position_uColor_frag.h b/cocos/2d/ccShader_Position_uColor_frag.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_Position_uColor_frag.h
rename to cocos/2d/ccShader_Position_uColor_frag.h
diff --git a/cocos/2d/shaders/ccShader_Position_uColor_vert.h b/cocos/2d/ccShader_Position_uColor_vert.h
similarity index 100%
rename from cocos/2d/shaders/ccShader_Position_uColor_vert.h
rename to cocos/2d/ccShader_Position_uColor_vert.h
diff --git a/cocos/2d/shaders/ccShaders.cpp b/cocos/2d/ccShaders.cpp
similarity index 100%
rename from cocos/2d/shaders/ccShaders.cpp
rename to cocos/2d/ccShaders.cpp
diff --git a/cocos/2d/shaders/ccShaders.h b/cocos/2d/ccShaders.h
similarity index 100%
rename from cocos/2d/shaders/ccShaders.h
rename to cocos/2d/ccShaders.h
diff --git a/cocos/2d/include/ccTypes.h b/cocos/2d/ccTypes.h
similarity index 100%
rename from cocos/2d/include/ccTypes.h
rename to cocos/2d/ccTypes.h
diff --git a/cocos/2d/support/ccUTF8.cpp b/cocos/2d/ccUTF8.cpp
similarity index 100%
rename from cocos/2d/support/ccUTF8.cpp
rename to cocos/2d/ccUTF8.cpp
diff --git a/cocos/2d/support/ccUTF8.h b/cocos/2d/ccUTF8.h
similarity index 100%
rename from cocos/2d/support/ccUTF8.h
rename to cocos/2d/ccUTF8.h
diff --git a/cocos/2d/support/ccUtils.h b/cocos/2d/ccUtils.h
similarity index 100%
rename from cocos/2d/support/ccUtils.h
rename to cocos/2d/ccUtils.h
diff --git a/cocos/2d/include/cocos2d.h b/cocos/2d/cocos2d.h
similarity index 100%
rename from cocos/2d/include/cocos2d.h
rename to cocos/2d/cocos2d.h
diff --git a/cocos/2d/proj.win32/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj
similarity index 100%
rename from cocos/2d/proj.win32/cocos2d.vcxproj
rename to cocos/2d/cocos2d.vcxproj
diff --git a/cocos/2d/proj.win32/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters
similarity index 100%
rename from cocos/2d/proj.win32/cocos2d.vcxproj.filters
rename to cocos/2d/cocos2d.vcxproj.filters
diff --git a/cocos/2d/proj.win32/cocos2d.vcxproj.user b/cocos/2d/cocos2d.vcxproj.user
similarity index 100%
rename from cocos/2d/proj.win32/cocos2d.vcxproj.user
rename to cocos/2d/cocos2d.vcxproj.user
diff --git a/cocos/2d/proj.linux/cocos2dx.mk b/cocos/2d/cocos2dx.mk
similarity index 100%
rename from cocos/2d/proj.linux/cocos2dx.mk
rename to cocos/2d/cocos2dx.mk
diff --git a/cocos/2d/proj.win32/cocos2dx.props b/cocos/2d/cocos2dx.props
similarity index 100%
rename from cocos/2d/proj.win32/cocos2dx.props
rename to cocos/2d/cocos2dx.props
diff --git a/cocos/2d/particle-nodes/firePngData.h b/cocos/2d/firePngData.h
similarity index 100%
rename from cocos/2d/particle-nodes/firePngData.h
rename to cocos/2d/firePngData.h
diff --git a/cocos/2d/proj.linux/.cproject b/cocos/2d/proj.linux/.cproject
deleted file mode 100755
index aaae232fb4..0000000000
--- a/cocos/2d/proj.linux/.cproject
+++ /dev/null
@@ -1,602 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cocos/2d/proj.linux/.project b/cocos/2d/proj.linux/.project
deleted file mode 100755
index 8811b56dd0..0000000000
--- a/cocos/2d/proj.linux/.project
+++ /dev/null
@@ -1,256 +0,0 @@
-
-
- libcocos2d
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
- ?name?
-
-
-
- org.eclipse.cdt.make.core.append_environment
- true
-
-
- org.eclipse.cdt.make.core.autoBuildTarget
- all
-
-
- org.eclipse.cdt.make.core.buildArguments
-
-
-
- org.eclipse.cdt.make.core.buildCommand
- make
-
-
- org.eclipse.cdt.make.core.buildLocation
- ${workspace_loc:/cocos2dx-base/Debug}
-
-
- org.eclipse.cdt.make.core.cleanBuildTarget
- clean
-
-
- org.eclipse.cdt.make.core.contents
- org.eclipse.cdt.make.core.activeConfigSettings
-
-
- org.eclipse.cdt.make.core.enableAutoBuild
- false
-
-
- org.eclipse.cdt.make.core.enableCleanBuild
- true
-
-
- org.eclipse.cdt.make.core.enableFullBuild
- true
-
-
- org.eclipse.cdt.make.core.fullBuildTarget
- all
-
-
- org.eclipse.cdt.make.core.stopOnError
- true
-
-
- org.eclipse.cdt.make.core.useDefaultBuildCmd
- true
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.core.ccnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
-
- CCCamera.cpp
- 1
- PARENT-1-PROJECT_LOC/CCCamera.cpp
-
-
- CCConfiguration.cpp
- 1
- PARENT-1-PROJECT_LOC/CCConfiguration.cpp
-
-
- CCConfiguration.h
- 1
- PARENT-1-PROJECT_LOC/CCConfiguration.h
-
-
- ccFPSImages.c
- 1
- PARENT-1-PROJECT_LOC/ccFPSImages.c
-
-
- ccFPSImages.h
- 1
- PARENT-1-PROJECT_LOC/ccFPSImages.h
-
-
- ccTypes.cpp
- 1
- PARENT-1-PROJECT_LOC/ccTypes.cpp
-
-
- CCDirector.cpp
- 1
- PARENT-1-PROJECT_LOC/CCDirector.cpp
-
-
- CCScheduler.cpp
- 1
- PARENT-1-PROJECT_LOC/CCScheduler.cpp
-
-
- actions
- 2
- PARENT-1-PROJECT_LOC/actions
-
-
- base_nodes
- 2
- PARENT-1-PROJECT_LOC/base_nodes
-
-
- cocoa
- 2
- PARENT-1-PROJECT_LOC/cocoa
-
-
- cocos2d.cpp
- 1
- PARENT-1-PROJECT_LOC/cocos2d.cpp
-
-
- draw_nodes
- 2
- PARENT-1-PROJECT_LOC/draw_nodes
-
-
- effects
- 2
- PARENT-1-PROJECT_LOC/effects
-
-
- include
- 2
- PARENT-1-PROJECT_LOC/include
-
-
- kazmath
- 2
- PARENT-1-PROJECT_LOC/kazmath
-
-
- keypad_dispatcher
- 2
- PARENT-1-PROJECT_LOC/keypad_dispatcher
-
-
- keyboard_dispatcher
- 2
- PARENT-1-PROJECT_LOC/keyboard_dispatcher
-
-
- label_nodes
- 2
- PARENT-1-PROJECT_LOC/label_nodes
-
-
- layers_scenes_transitions_nodes
- 2
- PARENT-1-PROJECT_LOC/layers_scenes_transitions_nodes
-
-
- menu_nodes
- 2
- PARENT-1-PROJECT_LOC/menu_nodes
-
-
- misc_nodes
- 2
- PARENT-1-PROJECT_LOC/misc_nodes
-
-
- particle_nodes
- 2
- PARENT-1-PROJECT_LOC/particle_nodes
-
-
- platform
- 2
- PARENT-1-PROJECT_LOC/platform
-
-
- script_support
- 2
- PARENT-1-PROJECT_LOC/script_support
-
-
- shaders
- 2
- PARENT-1-PROJECT_LOC/shaders
-
-
- sprite_nodes
- 2
- PARENT-1-PROJECT_LOC/sprite_nodes
-
-
- support
- 2
- PARENT-1-PROJECT_LOC/support
-
-
- text_input_node
- 2
- PARENT-1-PROJECT_LOC/text_input_node
-
-
- textures
- 2
- PARENT-1-PROJECT_LOC/textures
-
-
- tilemap_parallax_nodes
- 2
- PARENT-1-PROJECT_LOC/tilemap_parallax_nodes
-
-
- touch_dispatcher
- 2
- PARENT-1-PROJECT_LOC/touch_dispatcher
-
-
-
-
- 1360135975775
- platform
- 9
-
- org.eclipse.ui.ide.multiFilter
- 1.0-name-matches-true-false-linux
-
-
-
-
diff --git a/cocos/2d/proj.linux/cocos2dx.prf b/cocos/2d/proj.linux/cocos2dx.prf
deleted file mode 100644
index 1122180b53..0000000000
--- a/cocos/2d/proj.linux/cocos2dx.prf
+++ /dev/null
@@ -1,37 +0,0 @@
-################################################################################
-# Do not include this file in your project: see cocos2dx.pri.
-################################################################################
-
-linux {
- # Use OpenAL in default QtCreator project.
- isEmpty(COCOS2D_USE_FMOD):COCOS2D_USE_FMOD=0
-
- # Variables used when building libraries.
- CC_LIBRARY_DIR = $$PWD/../../lib/linux/release
- CC_MAKE_FLAGS = -s
- CONFIG(debug, debug|release) {
- # Override in debug build.
- CC_MAKE_FLAGS += DEBUG=1
- CC_LIBRARY_DIR = $$PWD/../../lib/linux/debug
- }
- contains(COCOS2D_MODULES,box2d) {
- CC_MAKE_FLAGS += USE_BOX2D=1
- }
- !equals(COCOS2D_USE_FMOD, 1) {
- CC_MAKE_FLAGS += OPENAL=1
- }
-
- # We will compile cocos2d shared library on demand using Makefile.
- build_cocos2d.name = Build cocos2d shared library
- build_cocos2d.input = $$PWD/Makefile
- build_cocos2d.output = $$CC_LIBRARY_DIR/libcocos2d.so
- build_cocos2d.target = $$CC_LIBRARY_DIR/libcocos2d.so
- build_cocos2d.CONFIG = no_link target_predeps
- build_cocos2d.commands = cd $$PWD && make $$CC_MAKE_FLAGS ${QMAKE_FILE_IN}
-
- QMAKE_EXTRA_COMPILERS += build_cocos2d
- QMAKE_EXTRA_TARGETS += build_cocos2d
-
- PRE_TARGETDEPS += $$CC_LIBRARY_DIR/libcocos2d.so
- LIBS += -L$$CC_LIBRARY_DIR -lcocos2d -Wl,-rpath,\'$$CC_LIBRARY_DIR\'
-}
diff --git a/cocos/2d/proj.linux/cocos2dx.pri b/cocos/2d/proj.linux/cocos2dx.pri
deleted file mode 100644
index 84bbb6d987..0000000000
--- a/cocos/2d/proj.linux/cocos2dx.pri
+++ /dev/null
@@ -1,70 +0,0 @@
-
-################################################################################
-#
-# If you want enable extra modules, set COCOS2D_MODULES variable before include
-# this file, example:
-# COCOS2D_MODULES += CocosDenshion
-# COCOS2D_MODULES += extensions
-# COCOS2D_MODULES += box2d
-# or
-# COCOS2D_MODULES += chipmunk
-# note: you cannot include both box2d and chipmunk.
-#
-# By default, QtCreator project will use OpenAL audio backend (because FMOD is
-# free only for non-commercial use). If you are legal FMOD user, set variable
-# COCOS2D_USE_FMOD to use FMOD audio backend:
-# COCOS2D_USE_FMOD = 1
-#
-################################################################################
-
-INCLUDEPATH += $$PWD/../
-INCLUDEPATH += $$PWD/../cocoa/
-INCLUDEPATH += $$PWD/../include/
-INCLUDEPATH += $$PWD/../platform/
-INCLUDEPATH += $$PWD/../kazmath/include
-
-*-msvc* {
- # Use equivalents of -Wno-overloaded-virtual -Wno-unused-parameter.
- QMAKE_CXXFLAGS_WARN_ON += /wd4263 /wd4100
-} else {
- QMAKE_CXXFLAGS_WARN_ON += -Wno-ignored-qualifiers -Wno-overloaded-virtual -Wno-unused-parameter -Wno-unused-function
- QMAKE_CXXFLAGS += -std=c++0x
-}
-
-include($$PWD/cocos2dx.prf)
-
-linux {
- DEFINES += LINUX
- INCLUDEPATH += $$PWD/../platform/linux
- LIBS += -lpthread
-}
-
-contains(COCOS2D_MODULES,CocosDenshion) {
- INCLUDEPATH += $$PWD/../../CocosDenshion/include
- include($$PWD/../../CocosDenshion/proj.linux/CocosDenshion.prf)
-}
-
-contains(COCOS2D_MODULES,extensions) {
- INCLUDEPATH += $$PWD/../../extensions
- LIBS += -lcurl
- include($$PWD/../../extensions/proj.linux/extensions.prf)
-}
-
-contains(COCOS2D_MODULES,box2d) {
- INCLUDEPATH += $$PWD/../../external
- include($$PWD/../../external/Box2D/proj.linux/box2d.prf)
-}
-
-contains(COCOS2D_MODULES,chipmunk) {
- contains(COCOS2D_MODULES,box2d):error("COCOS2D_MODULES cannot contain both box2d and chipmunk: choose one and remove another.")
-
- INCLUDEPATH += $$PWD/../../external/chipmunk/include/chipmunk
- include($$PWD/../../external/chipmunk/proj.linux/chipmunk.prf)
-}
-
-CONFIG(debug, debug|release) {
- DEFINES += COCOS2D_DEBUG=1
-}
-else {
- DEFINES += COCOS2D_DEBUG=0
-}
diff --git a/cocos/2d/support/ccUtils.cpp b/cocos/2d/support/ccUtils.cpp
deleted file mode 100644
index d78324565b..0000000000
--- a/cocos/2d/support/ccUtils.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/****************************************************************************
-Copyright (c) 2010 cocos2d-x.org
-
-http://www.cocos2d-x.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-****************************************************************************/
-#include "ccUtils.h"
-
-namespace cocos2d {
-
-unsigned long ccNextPOT(unsigned long x)
-{
- x = x - 1;
- x = x | (x >> 1);
- x = x | (x >> 2);
- x = x | (x >> 4);
- x = x | (x >> 8);
- x = x | (x >>16);
- return x + 1;
-}
-
-}
\ No newline at end of file
diff --git a/cocos/2d/support/tinyxml2/tinyxml2.cpp b/cocos/2d/support/tinyxml2/tinyxml2.cpp
deleted file mode 100644
index f181b9050c..0000000000
--- a/cocos/2d/support/tinyxml2/tinyxml2.cpp
+++ /dev/null
@@ -1,2101 +0,0 @@
-/*
-Original code by Lee Thomason (www.grinninglizard.com)
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-#include "tinyxml2.h"
-
-#include // yes, this one new style header, is in the Android SDK.
-# if defined(ANDROID_NDK) || (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY)
-# include
-#else
-# include
-#endif
-
-static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF
-static const char LF = LINE_FEED;
-static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out
-static const char CR = CARRIAGE_RETURN;
-static const char SINGLE_QUOTE = '\'';
-static const char DOUBLE_QUOTE = '\"';
-
-// Bunch of unicode info at:
-// http://www.unicode.org/faq/utf_bom.html
-// ef bb bf (Microsoft "lead bytes") - designates UTF-8
-
-static const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
-static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
-static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
-
-
-#define DELETE_NODE( node ) { \
- if ( node ) { \
- MemPool* pool = node->_memPool; \
- node->~XMLNode(); \
- pool->Free( node ); \
- } \
- }
-#define DELETE_ATTRIBUTE( attrib ) { \
- if ( attrib ) { \
- MemPool* pool = attrib->_memPool; \
- attrib->~XMLAttribute(); \
- pool->Free( attrib ); \
- } \
- }
-
-namespace tinyxml2
-{
-
-struct Entity {
- const char* pattern;
- int length;
- char value;
-};
-
-static const int NUM_ENTITIES = 5;
-static const Entity entities[NUM_ENTITIES] = {
- { "quot", 4, DOUBLE_QUOTE },
- { "amp", 3, '&' },
- { "apos", 4, SINGLE_QUOTE },
- { "lt", 2, '<' },
- { "gt", 2, '>' }
-};
-
-
-StrPair::~StrPair()
-{
- Reset();
-}
-
-
-void StrPair::Reset()
-{
- if ( _flags & NEEDS_DELETE ) {
- delete [] _start;
- }
- _flags = 0;
- _start = 0;
- _end = 0;
-}
-
-
-void StrPair::SetStr( const char* str, int flags )
-{
- Reset();
- size_t len = strlen( str );
- _start = new char[ len+1 ];
- memcpy( _start, str, len+1 );
- _end = _start + len;
- _flags = flags | NEEDS_DELETE;
-}
-
-
-char* StrPair::ParseText( char* p, const char* endTag, int strFlags )
-{
- TIXMLASSERT( endTag && *endTag );
-
- char* start = p; // fixme: hides a member
- char endChar = *endTag;
- size_t length = strlen( endTag );
-
- // Inner loop of text parsing.
- while ( *p ) {
- if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) {
- Set( start, p, strFlags );
- return p + length;
- }
- ++p;
- }
- return 0;
-}
-
-
-char* StrPair::ParseName( char* p )
-{
- char* start = p;
-
- if ( !start || !(*start) ) {
- return 0;
- }
-
- while( *p && (
- XMLUtil::IsAlphaNum( (unsigned char) *p )
- || *p == '_'
- || *p == ':'
- || (*p == '-' && p>start ) // can be in a name, but not lead it.
- || (*p == '.' && p>start ) )) { // can be in a name, but not lead it.
- ++p;
- }
-
- if ( p > start ) {
- Set( start, p, 0 );
- return p;
- }
- return 0;
-}
-
-
-void StrPair::CollapseWhitespace()
-{
- // Trim leading space.
- _start = XMLUtil::SkipWhiteSpace( _start );
-
- if ( _start && *_start ) {
- char* p = _start; // the read pointer
- char* q = _start; // the write pointer
-
- while( *p ) {
- if ( XMLUtil::IsWhiteSpace( *p )) {
- p = XMLUtil::SkipWhiteSpace( p );
- if ( *p == 0 ) {
- break; // don't write to q; this trims the trailing space.
- }
- *q = ' ';
- ++q;
- }
- *q = *p;
- ++q;
- ++p;
- }
- *q = 0;
- }
-}
-
-
-const char* StrPair::GetStr()
-{
- if ( _flags & NEEDS_FLUSH ) {
- *_end = 0;
- _flags ^= NEEDS_FLUSH;
-
- if ( _flags ) {
- char* p = _start; // the read pointer
- char* q = _start; // the write pointer
-
- while( p < _end ) {
- if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) {
- // CR-LF pair becomes LF
- // CR alone becomes LF
- // LF-CR becomes LF
- if ( *(p+1) == LF ) {
- p += 2;
- }
- else {
- ++p;
- }
- *q++ = LF;
- }
- else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) {
- if ( *(p+1) == CR ) {
- p += 2;
- }
- else {
- ++p;
- }
- *q++ = LF;
- }
- else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) {
- // Entities handled by tinyXML2:
- // - special entities in the entity table [in/out]
- // - numeric character reference [in]
- // 中 or 中
-
- if ( *(p+1) == '#' ) {
- char buf[10] = { 0 };
- int len;
- p = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) );
- for( int i=0; i(p);
- // Check for BOM:
- if ( *(pu+0) == TIXML_UTF_LEAD_0
- && *(pu+1) == TIXML_UTF_LEAD_1
- && *(pu+2) == TIXML_UTF_LEAD_2 ) {
- *bom = true;
- p += 3;
- }
- return p;
-}
-
-
-void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length )
-{
- const unsigned long BYTE_MASK = 0xBF;
- const unsigned long BYTE_MARK = 0x80;
- const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
-
- if (input < 0x80) {
- *length = 1;
- }
- else if ( input < 0x800 ) {
- *length = 2;
- }
- else if ( input < 0x10000 ) {
- *length = 3;
- }
- else if ( input < 0x200000 ) {
- *length = 4;
- }
- else {
- *length = 0; // This code won't covert this correctly anyway.
- return;
- }
-
- output += *length;
-
- // Scary scary fall throughs.
- switch (*length) {
- case 4:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 3:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 2:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 1:
- --output;
- *output = (char)(input | FIRST_BYTE_MARK[*length]);
- default:
- break;
- }
-}
-
-
-const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length )
-{
- // Presume an entity, and pull it out.
- *length = 0;
-
- if ( *(p+1) == '#' && *(p+2) ) {
- unsigned long ucs = 0;
- ptrdiff_t delta = 0;
- unsigned mult = 1;
-
- if ( *(p+2) == 'x' ) {
- // Hexadecimal.
- if ( !*(p+3) ) {
- return 0;
- }
-
- const char* q = p+3;
- q = strchr( q, ';' );
-
- if ( !q || !*q ) {
- return 0;
- }
-
- delta = q-p;
- --q;
-
- while ( *q != 'x' ) {
- if ( *q >= '0' && *q <= '9' ) {
- ucs += mult * (*q - '0');
- }
- else if ( *q >= 'a' && *q <= 'f' ) {
- ucs += mult * (*q - 'a' + 10);
- }
- else if ( *q >= 'A' && *q <= 'F' ) {
- ucs += mult * (*q - 'A' + 10 );
- }
- else {
- return 0;
- }
- mult *= 16;
- --q;
- }
- }
- else {
- // Decimal.
- if ( !*(p+2) ) {
- return 0;
- }
-
- const char* q = p+2;
- q = strchr( q, ';' );
-
- if ( !q || !*q ) {
- return 0;
- }
-
- delta = q-p;
- --q;
-
- while ( *q != '#' ) {
- if ( *q >= '0' && *q <= '9' ) {
- ucs += mult * (*q - '0');
- }
- else {
- return 0;
- }
- mult *= 10;
- --q;
- }
- }
- // convert the UCS to UTF-8
- ConvertUTF32ToUTF8( ucs, value, length );
- return p + delta + 1;
- }
- return p+1;
-}
-
-
-void XMLUtil::ToStr( int v, char* buffer, int bufferSize )
-{
- TIXML_SNPRINTF( buffer, bufferSize, "%d", v );
-}
-
-
-void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize )
-{
- TIXML_SNPRINTF( buffer, bufferSize, "%u", v );
-}
-
-
-void XMLUtil::ToStr( bool v, char* buffer, int bufferSize )
-{
- TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 );
-}
-
-
-void XMLUtil::ToStr( float v, char* buffer, int bufferSize )
-{
- TIXML_SNPRINTF( buffer, bufferSize, "%g", v );
-}
-
-
-void XMLUtil::ToStr( double v, char* buffer, int bufferSize )
-{
- TIXML_SNPRINTF( buffer, bufferSize, "%g", v );
-}
-
-
-bool XMLUtil::ToInt( const char* str, int* value )
-{
- if ( TIXML_SSCANF( str, "%d", value ) == 1 ) {
- return true;
- }
- return false;
-}
-
-bool XMLUtil::ToUnsigned( const char* str, unsigned *value )
-{
- if ( TIXML_SSCANF( str, "%u", value ) == 1 ) {
- return true;
- }
- return false;
-}
-
-bool XMLUtil::ToBool( const char* str, bool* value )
-{
- int ival = 0;
- if ( ToInt( str, &ival )) {
- *value = (ival==0) ? false : true;
- return true;
- }
- if ( StringEqual( str, "true" ) ) {
- *value = true;
- return true;
- }
- else if ( StringEqual( str, "false" ) ) {
- *value = false;
- return true;
- }
- return false;
-}
-
-
-bool XMLUtil::ToFloat( const char* str, float* value )
-{
- if ( TIXML_SSCANF( str, "%f", value ) == 1 ) {
- return true;
- }
- return false;
-}
-
-bool XMLUtil::ToDouble( const char* str, double* value )
-{
- if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) {
- return true;
- }
- return false;
-}
-
-
-char* XMLDocument::Identify( char* p, XMLNode** node )
-{
- XMLNode* returnNode = 0;
- char* start = p;
- p = XMLUtil::SkipWhiteSpace( p );
- if( !p || !*p ) {
- return p;
- }
-
- // What is this thing?
- // - Elements start with a letter or underscore, but xml is reserved.
- // - Comments:
- //
- // With a special case:
- //
- //
- //
- //
- // Where the closing element (/foo) *must* be the next thing after the opening
- // element, and the names must match. BUT the tricky bit is that the closing
- // element will be read by the child.
- //
- // 'endTag' is the end tag for this node, it is returned by a call to a child.
- // 'parentEnd' is the end tag for the parent, which is filled in and returned.
-
- while( p && *p ) {
- XMLNode* node = 0;
-
- p = _document->Identify( p, &node );
- if ( p == 0 || node == 0 ) {
- break;
- }
-
- StrPair endTag;
- p = node->ParseDeep( p, &endTag );
- if ( !p ) {
- DELETE_NODE( node );
- node = 0;
- if ( !_document->Error() ) {
- _document->SetError( XML_ERROR_PARSING, 0, 0 );
- }
- break;
- }
-
- // We read the end tag. Return it to the parent.
- if ( node->ToElement() && node->ToElement()->ClosingType() == XMLElement::CLOSING ) {
- if ( parentEnd ) {
- *parentEnd = static_cast(node)->_value;
- }
- node->_memPool->SetTracked(); // created and then immediately deleted.
- DELETE_NODE( node );
- return p;
- }
-
- // Handle an end tag returned to this level.
- // And handle a bunch of annoying errors.
- XMLElement* ele = node->ToElement();
- if ( ele ) {
- if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) {
- _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
- p = 0;
- }
- else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) {
- _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
- p = 0;
- }
- else if ( !endTag.Empty() ) {
- if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) {
- _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
- p = 0;
- }
- }
- }
- if ( p == 0 ) {
- DELETE_NODE( node );
- node = 0;
- }
- if ( node ) {
- this->InsertEndChild( node );
- }
- }
- return 0;
-}
-
-// --------- XMLText ---------- //
-char* XMLText::ParseDeep( char* p, StrPair* )
-{
- const char* start = p;
- if ( this->CData() ) {
- p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION );
- if ( !p ) {
- _document->SetError( XML_ERROR_PARSING_CDATA, start, 0 );
- }
- return p;
- }
- else {
- int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES;
- if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) {
- flags |= StrPair::COLLAPSE_WHITESPACE;
- }
-
- p = _value.ParseText( p, "<", flags );
- if ( !p ) {
- _document->SetError( XML_ERROR_PARSING_TEXT, start, 0 );
- }
- if ( p && *p ) {
- return p-1;
- }
- }
- return 0;
-}
-
-
-XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const
-{
- if ( !doc ) {
- doc = _document;
- }
- XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern?
- text->SetCData( this->CData() );
- return text;
-}
-
-
-bool XMLText::ShallowEqual( const XMLNode* compare ) const
-{
- return ( compare->ToText() && XMLUtil::StringEqual( compare->ToText()->Value(), Value() ));
-}
-
-
-bool XMLText::Accept( XMLVisitor* visitor ) const
-{
- return visitor->Visit( *this );
-}
-
-
-// --------- XMLComment ---------- //
-
-XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc )
-{
-}
-
-
-XMLComment::~XMLComment()
-{
-}
-
-
-char* XMLComment::ParseDeep( char* p, StrPair* )
-{
- // Comment parses as text.
- const char* start = p;
- p = _value.ParseText( p, "-->", StrPair::COMMENT );
- if ( p == 0 ) {
- _document->SetError( XML_ERROR_PARSING_COMMENT, start, 0 );
- }
- return p;
-}
-
-
-XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const
-{
- if ( !doc ) {
- doc = _document;
- }
- XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern?
- return comment;
-}
-
-
-bool XMLComment::ShallowEqual( const XMLNode* compare ) const
-{
- return ( compare->ToComment() && XMLUtil::StringEqual( compare->ToComment()->Value(), Value() ));
-}
-
-
-bool XMLComment::Accept( XMLVisitor* visitor ) const
-{
- return visitor->Visit( *this );
-}
-
-
-// --------- XMLDeclaration ---------- //
-
-XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc )
-{
-}
-
-
-XMLDeclaration::~XMLDeclaration()
-{
- //printf( "~XMLDeclaration\n" );
-}
-
-
-char* XMLDeclaration::ParseDeep( char* p, StrPair* )
-{
- // Declaration parses as text.
- const char* start = p;
- p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION );
- if ( p == 0 ) {
- _document->SetError( XML_ERROR_PARSING_DECLARATION, start, 0 );
- }
- return p;
-}
-
-
-XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const
-{
- if ( !doc ) {
- doc = _document;
- }
- XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern?
- return dec;
-}
-
-
-bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const
-{
- return ( compare->ToDeclaration() && XMLUtil::StringEqual( compare->ToDeclaration()->Value(), Value() ));
-}
-
-
-
-bool XMLDeclaration::Accept( XMLVisitor* visitor ) const
-{
- return visitor->Visit( *this );
-}
-
-// --------- XMLUnknown ---------- //
-
-XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc )
-{
-}
-
-
-XMLUnknown::~XMLUnknown()
-{
-}
-
-
-char* XMLUnknown::ParseDeep( char* p, StrPair* )
-{
- // Unknown parses as text.
- const char* start = p;
-
- p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION );
- if ( !p ) {
- _document->SetError( XML_ERROR_PARSING_UNKNOWN, start, 0 );
- }
- return p;
-}
-
-
-XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const
-{
- if ( !doc ) {
- doc = _document;
- }
- XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern?
- return text;
-}
-
-
-bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const
-{
- return ( compare->ToUnknown() && XMLUtil::StringEqual( compare->ToUnknown()->Value(), Value() ));
-}
-
-
-bool XMLUnknown::Accept( XMLVisitor* visitor ) const
-{
- return visitor->Visit( *this );
-}
-
-// --------- XMLAttribute ---------- //
-char* XMLAttribute::ParseDeep( char* p, bool processEntities )
-{
- // Parse using the name rules: bug fix, was using ParseText before
- p = _name.ParseName( p );
- if ( !p || !*p ) {
- return 0;
- }
-
- // Skip white space before =
- p = XMLUtil::SkipWhiteSpace( p );
- if ( !p || *p != '=' ) {
- return 0;
- }
-
- ++p; // move up to opening quote
- p = XMLUtil::SkipWhiteSpace( p );
- if ( *p != '\"' && *p != '\'' ) {
- return 0;
- }
-
- char endTag[2] = { *p, 0 };
- ++p; // move past opening quote
-
- p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES );
- return p;
-}
-
-
-void XMLAttribute::SetName( const char* n )
-{
- _name.SetStr( n );
-}
-
-
-XMLError XMLAttribute::QueryIntValue( int* value ) const
-{
- if ( XMLUtil::ToInt( Value(), value )) {
- return XML_NO_ERROR;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const
-{
- if ( XMLUtil::ToUnsigned( Value(), value )) {
- return XML_NO_ERROR;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-XMLError XMLAttribute::QueryBoolValue( bool* value ) const
-{
- if ( XMLUtil::ToBool( Value(), value )) {
- return XML_NO_ERROR;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-XMLError XMLAttribute::QueryFloatValue( float* value ) const
-{
- if ( XMLUtil::ToFloat( Value(), value )) {
- return XML_NO_ERROR;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-XMLError XMLAttribute::QueryDoubleValue( double* value ) const
-{
- if ( XMLUtil::ToDouble( Value(), value )) {
- return XML_NO_ERROR;
- }
- return XML_WRONG_ATTRIBUTE_TYPE;
-}
-
-
-void XMLAttribute::SetAttribute( const char* v )
-{
- _value.SetStr( v );
-}
-
-
-void XMLAttribute::SetAttribute( int v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- _value.SetStr( buf );
-}
-
-
-void XMLAttribute::SetAttribute( unsigned v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- _value.SetStr( buf );
-}
-
-
-void XMLAttribute::SetAttribute( bool v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- _value.SetStr( buf );
-}
-
-void XMLAttribute::SetAttribute( double v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- _value.SetStr( buf );
-}
-
-void XMLAttribute::SetAttribute( float v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- _value.SetStr( buf );
-}
-
-
-// --------- XMLElement ---------- //
-XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ),
- _closingType( 0 ),
- _rootAttribute( 0 )
-{
-}
-
-
-XMLElement::~XMLElement()
-{
- while( _rootAttribute ) {
- XMLAttribute* next = _rootAttribute->_next;
- DELETE_ATTRIBUTE( _rootAttribute );
- _rootAttribute = next;
- }
-}
-
-
-XMLAttribute* XMLElement::FindAttribute( const char* name )
-{
- XMLAttribute* a = 0;
- for( a=_rootAttribute; a; a = a->_next ) {
- if ( XMLUtil::StringEqual( a->Name(), name ) ) {
- return a;
- }
- }
- return 0;
-}
-
-
-const XMLAttribute* XMLElement::FindAttribute( const char* name ) const
-{
- XMLAttribute* a = 0;
- for( a=_rootAttribute; a; a = a->_next ) {
- if ( XMLUtil::StringEqual( a->Name(), name ) ) {
- return a;
- }
- }
- return 0;
-}
-
-
-const char* XMLElement::Attribute( const char* name, const char* value ) const
-{
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return 0;
- }
- if ( !value || XMLUtil::StringEqual( a->Value(), value )) {
- return a->Value();
- }
- return 0;
-}
-
-
-const char* XMLElement::GetText() const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- return FirstChild()->ToText()->Value();
- }
- return 0;
-}
-
-
-XMLError XMLElement::QueryIntText( int* ival ) const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- const char* t = FirstChild()->ToText()->Value();
- if ( XMLUtil::ToInt( t, ival ) ) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-
-XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- const char* t = FirstChild()->ToText()->Value();
- if ( XMLUtil::ToUnsigned( t, uval ) ) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-
-XMLError XMLElement::QueryBoolText( bool* bval ) const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- const char* t = FirstChild()->ToText()->Value();
- if ( XMLUtil::ToBool( t, bval ) ) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-
-XMLError XMLElement::QueryDoubleText( double* dval ) const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- const char* t = FirstChild()->ToText()->Value();
- if ( XMLUtil::ToDouble( t, dval ) ) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-
-XMLError XMLElement::QueryFloatText( float* fval ) const
-{
- if ( FirstChild() && FirstChild()->ToText() ) {
- const char* t = FirstChild()->ToText()->Value();
- if ( XMLUtil::ToFloat( t, fval ) ) {
- return XML_SUCCESS;
- }
- return XML_CAN_NOT_CONVERT_TEXT;
- }
- return XML_NO_TEXT_NODE;
-}
-
-
-
-XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
-{
- XMLAttribute* last = 0;
- XMLAttribute* attrib = 0;
- for( attrib = _rootAttribute;
- attrib;
- last = attrib, attrib = attrib->_next ) {
- if ( XMLUtil::StringEqual( attrib->Name(), name ) ) {
- break;
- }
- }
- if ( !attrib ) {
- attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
- attrib->_memPool = &_document->_attributePool;
- if ( last ) {
- last->_next = attrib;
- }
- else {
- _rootAttribute = attrib;
- }
- attrib->SetName( name );
- attrib->_memPool->SetTracked(); // always created and linked.
- }
- return attrib;
-}
-
-
-void XMLElement::DeleteAttribute( const char* name )
-{
- XMLAttribute* prev = 0;
- for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) {
- if ( XMLUtil::StringEqual( name, a->Name() ) ) {
- if ( prev ) {
- prev->_next = a->_next;
- }
- else {
- _rootAttribute = a->_next;
- }
- DELETE_ATTRIBUTE( a );
- break;
- }
- prev = a;
- }
-}
-
-
-char* XMLElement::ParseAttributes( char* p )
-{
- const char* start = p;
- XMLAttribute* prevAttribute = 0;
-
- // Read the attributes.
- while( p ) {
- p = XMLUtil::SkipWhiteSpace( p );
- if ( !p || !(*p) ) {
- _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() );
- return 0;
- }
-
- // attribute.
- if ( XMLUtil::IsAlpha( *p ) ) {
- XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
- attrib->_memPool = &_document->_attributePool;
- attrib->_memPool->SetTracked();
-
- p = attrib->ParseDeep( p, _document->ProcessEntities() );
- if ( !p || Attribute( attrib->Name() ) ) {
- DELETE_ATTRIBUTE( attrib );
- _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p );
- return 0;
- }
- // There is a minor bug here: if the attribute in the source xml
- // document is duplicated, it will not be detected and the
- // attribute will be doubly added. However, tracking the 'prevAttribute'
- // avoids re-scanning the attribute list. Preferring performance for
- // now, may reconsider in the future.
- if ( prevAttribute ) {
- prevAttribute->_next = attrib;
- }
- else {
- _rootAttribute = attrib;
- }
- prevAttribute = attrib;
- }
- // end of the tag
- else if ( *p == '/' && *(p+1) == '>' ) {
- _closingType = CLOSED;
- return p+2; // done; sealed element.
- }
- // end of the tag
- else if ( *p == '>' ) {
- ++p;
- break;
- }
- else {
- _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p );
- return 0;
- }
- }
- return p;
-}
-
-
-//
-//
-// foobar
-//
-char* XMLElement::ParseDeep( char* p, StrPair* strPair )
-{
- // Read the element name.
- p = XMLUtil::SkipWhiteSpace( p );
- if ( !p ) {
- return 0;
- }
-
- // The closing element is the form. It is
- // parsed just like a regular element then deleted from
- // the DOM.
- if ( *p == '/' ) {
- _closingType = CLOSING;
- ++p;
- }
-
- p = _value.ParseName( p );
- if ( _value.Empty() ) {
- return 0;
- }
-
- p = ParseAttributes( p );
- if ( !p || !*p || _closingType ) {
- return p;
- }
-
- p = XMLNode::ParseDeep( p, strPair );
- return p;
-}
-
-
-
-XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const
-{
- if ( !doc ) {
- doc = _document;
- }
- XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern?
- for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) {
- element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern?
- }
- return element;
-}
-
-
-bool XMLElement::ShallowEqual( const XMLNode* compare ) const
-{
- const XMLElement* other = compare->ToElement();
- if ( other && XMLUtil::StringEqual( other->Value(), Value() )) {
-
- const XMLAttribute* a=FirstAttribute();
- const XMLAttribute* b=other->FirstAttribute();
-
- while ( a && b ) {
- if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) {
- return false;
- }
- a = a->Next();
- b = b->Next();
- }
- if ( a || b ) {
- // different count
- return false;
- }
- return true;
- }
- return false;
-}
-
-
-bool XMLElement::Accept( XMLVisitor* visitor ) const
-{
- if ( visitor->VisitEnter( *this, _rootAttribute ) ) {
- for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) {
- if ( !node->Accept( visitor ) ) {
- break;
- }
- }
- }
- return visitor->VisitExit( *this );
-}
-
-
-// --------- XMLDocument ----------- //
-XMLDocument::XMLDocument( bool processEntities, Whitespace whitespace ) :
- XMLNode( 0 ),
- _writeBOM( false ),
- _processEntities( processEntities ),
- _errorID( XML_NO_ERROR ),
- _whitespace( whitespace ),
- _errorStr1( 0 ),
- _errorStr2( 0 ),
- _charBuffer( 0 )
-{
- _document = this; // avoid warning about 'this' in initializer list
-}
-
-
-XMLDocument::~XMLDocument()
-{
- DeleteChildren();
- delete [] _charBuffer;
-
-#if 0
- textPool.Trace( "text" );
- elementPool.Trace( "element" );
- commentPool.Trace( "comment" );
- attributePool.Trace( "attribute" );
-#endif
-
-#ifdef DEBUG
- if ( Error() == false ) {
- TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() );
- TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() );
- TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() );
- TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() );
- }
-#endif
-}
-
-
-void XMLDocument::InitDocument()
-{
- _errorID = XML_NO_ERROR;
- _errorStr1 = 0;
- _errorStr2 = 0;
-
- delete [] _charBuffer;
- _charBuffer = 0;
-}
-
-
-XMLElement* XMLDocument::NewElement( const char* name )
-{
- XMLElement* ele = new (_elementPool.Alloc()) XMLElement( this );
- ele->_memPool = &_elementPool;
- ele->SetName( name );
- return ele;
-}
-
-
-XMLComment* XMLDocument::NewComment( const char* str )
-{
- XMLComment* comment = new (_commentPool.Alloc()) XMLComment( this );
- comment->_memPool = &_commentPool;
- comment->SetValue( str );
- return comment;
-}
-
-
-XMLText* XMLDocument::NewText( const char* str )
-{
- XMLText* text = new (_textPool.Alloc()) XMLText( this );
- text->_memPool = &_textPool;
- text->SetValue( str );
- return text;
-}
-
-
-XMLDeclaration* XMLDocument::NewDeclaration( const char* str )
-{
- XMLDeclaration* dec = new (_commentPool.Alloc()) XMLDeclaration( this );
- dec->_memPool = &_commentPool;
- dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" );
- return dec;
-}
-
-
-XMLUnknown* XMLDocument::NewUnknown( const char* str )
-{
- XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown( this );
- unk->_memPool = &_commentPool;
- unk->SetValue( str );
- return unk;
-}
-
-
-XMLError XMLDocument::LoadFile( const char* filename )
-{
- DeleteChildren();
- InitDocument();
- FILE* fp = 0;
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
- errno_t err = fopen_s(&fp, filename, "rb" );
- if ( !fp || err) {
-#else
- fp = fopen( filename, "rb" );
- if ( !fp) {
-#endif
- SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 );
- return _errorID;
- }
- LoadFile( fp );
- fclose( fp );
- return _errorID;
-}
-
-
-XMLError XMLDocument::LoadFile( FILE* fp )
-{
- DeleteChildren();
- InitDocument();
-
- fseek( fp, 0, SEEK_END );
- size_t size = ftell( fp );
- fseek( fp, 0, SEEK_SET );
-
- if ( size == 0 ) {
- return _errorID;
- }
-
- _charBuffer = new char[size+1];
- size_t read = fread( _charBuffer, 1, size, fp );
- if ( read != size ) {
- SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
- return _errorID;
- }
-
- _charBuffer[size] = 0;
-
- const char* p = _charBuffer;
- p = XMLUtil::SkipWhiteSpace( p );
- p = XMLUtil::ReadBOM( p, &_writeBOM );
- if ( !p || !*p ) {
- SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
- return _errorID;
- }
-
- ParseDeep( _charBuffer + (p-_charBuffer), 0 );
- return _errorID;
-}
-
-
-XMLError XMLDocument::SaveFile( const char* filename, bool compact )
-{
- FILE* fp = 0;
-#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
- errno_t err = fopen_s(&fp, filename, "w" );
- if ( !fp || err) {
-#else
- fp = fopen( filename, "w" );
- if ( !fp) {
-#endif
- SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 );
- return _errorID;
- }
- SaveFile(fp, compact);
- fclose( fp );
- return _errorID;
-}
-
-
-XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
-{
- XMLPrinter stream( fp, compact );
- Print( &stream );
- return _errorID;
-}
-
-
-XMLError XMLDocument::Parse( const char* p, size_t len )
-{
- DeleteChildren();
- InitDocument();
-
- if ( !p || !*p ) {
- SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
- return _errorID;
- }
- if ( len == (size_t)(-1) ) {
- len = strlen( p );
- }
- _charBuffer = new char[ len+1 ];
- memcpy( _charBuffer, p, len );
- _charBuffer[len] = 0;
-
- p = XMLUtil::SkipWhiteSpace( p );
- p = XMLUtil::ReadBOM( p, &_writeBOM );
- if ( !p || !*p ) {
- SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
- return _errorID;
- }
-
- ParseDeep( _charBuffer, 0 );
- return _errorID;
-}
-
-
-void XMLDocument::Print( XMLPrinter* streamer )
-{
- XMLPrinter stdStreamer( stdout );
- if ( !streamer ) {
- streamer = &stdStreamer;
- }
- Accept( streamer );
-}
-
-
-void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 )
-{
- _errorID = error;
- _errorStr1 = str1;
- _errorStr2 = str2;
-}
-
-
-void XMLDocument::PrintError() const
-{
- if ( _errorID ) {
- static const int LEN = 20;
- char buf1[LEN] = { 0 };
- char buf2[LEN] = { 0 };
-
- if ( _errorStr1 ) {
- TIXML_SNPRINTF( buf1, LEN, "%s", _errorStr1 );
- }
- if ( _errorStr2 ) {
- TIXML_SNPRINTF( buf2, LEN, "%s", _errorStr2 );
- }
-
- printf( "XMLDocument error id=%d str1=%s str2=%s\n",
- _errorID, buf1, buf2 );
- }
-}
-
-
-XMLPrinter::XMLPrinter( FILE* file, bool compact ) :
- _elementJustOpened( false ),
- _firstElement( true ),
- _fp( file ),
- _depth( 0 ),
- _textDepth( -1 ),
- _processEntities( true ),
- _compactMode( compact )
-{
- for( int i=0; i'] = true; // not required, but consistency is nice
- _buffer.Push( 0 );
-}
-
-
-void XMLPrinter::Print( const char* format, ... )
-{
- va_list va;
- va_start( va, format );
-
- if ( _fp ) {
- vfprintf( _fp, format, va );
- }
- else {
- // This seems brutally complex. Haven't figured out a better
- // way on windows.
-#if defined _MSC_VER && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
- int len = -1;
- int expand = 1000;
- while ( len < 0 ) {
- len = vsnprintf_s( _accumulator.Mem(), _accumulator.Capacity(), _TRUNCATE, format, va );
- if ( len < 0 ) {
- expand *= 3/2;
- _accumulator.PushArr( expand );
- }
- }
- char* p = _buffer.PushArr( len ) - 1;
- memcpy( p, _accumulator.Mem(), len+1 );
-#else
- int len = vsnprintf( 0, 0, format, va );
- // Close out and re-start the va-args
- va_end( va );
- va_start( va, format );
- char* p = _buffer.PushArr( len ) - 1;
- vsnprintf( p, len+1, format, va );
-#endif
- }
- va_end( va );
-}
-
-
-void XMLPrinter::PrintSpace( int depth )
-{
- for( int i=0; i 0 && *q < ENTITY_RANGE ) {
- // Check for entities. If one is found, flush
- // the stream up until the entity, write the
- // entity, and keep looking.
- if ( flag[(unsigned)(*q)] ) {
- while ( p < q ) {
- Print( "%c", *p );
- ++p;
- }
- for( int i=0; i 0) ) {
- Print( "%s", p );
- }
-}
-
-
-void XMLPrinter::PushHeader( bool writeBOM, bool writeDec )
-{
- static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 };
- if ( writeBOM ) {
- Print( "%s", bom );
- }
- if ( writeDec ) {
- PushDeclaration( "xml version=\"1.0\"" );
- }
-}
-
-
-void XMLPrinter::OpenElement( const char* name )
-{
- if ( _elementJustOpened ) {
- SealElement();
- }
- _stack.Push( name );
-
- if ( _textDepth < 0 && !_firstElement && !_compactMode ) {
- Print( "\n" );
- PrintSpace( _depth );
- }
-
- Print( "<%s", name );
- _elementJustOpened = true;
- _firstElement = false;
- ++_depth;
-}
-
-
-void XMLPrinter::PushAttribute( const char* name, const char* value )
-{
- TIXMLASSERT( _elementJustOpened );
- Print( " %s=\"", name );
- PrintString( value, false );
- Print( "\"" );
-}
-
-
-void XMLPrinter::PushAttribute( const char* name, int v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- PushAttribute( name, buf );
-}
-
-
-void XMLPrinter::PushAttribute( const char* name, unsigned v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- PushAttribute( name, buf );
-}
-
-
-void XMLPrinter::PushAttribute( const char* name, bool v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- PushAttribute( name, buf );
-}
-
-
-void XMLPrinter::PushAttribute( const char* name, double v )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( v, buf, BUF_SIZE );
- PushAttribute( name, buf );
-}
-
-
-void XMLPrinter::CloseElement()
-{
- --_depth;
- const char* name = _stack.Pop();
-
- if ( _elementJustOpened ) {
- Print( "/>" );
- }
- else {
- if ( _textDepth < 0 && !_compactMode) {
- Print( "\n" );
- PrintSpace( _depth );
- }
- Print( "%s>", name );
- }
-
- if ( _textDepth == _depth ) {
- _textDepth = -1;
- }
- if ( _depth == 0 && !_compactMode) {
- Print( "\n" );
- }
- _elementJustOpened = false;
-}
-
-
-void XMLPrinter::SealElement()
-{
- _elementJustOpened = false;
- Print( ">" );
-}
-
-
-void XMLPrinter::PushText( const char* text, bool cdata )
-{
- _textDepth = _depth-1;
-
- if ( _elementJustOpened ) {
- SealElement();
- }
- if ( cdata ) {
- Print( "" );
- }
- else {
- PrintString( text, true );
- }
-}
-
-void XMLPrinter::PushText( int value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-
-void XMLPrinter::PushText( unsigned value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-
-void XMLPrinter::PushText( bool value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-
-void XMLPrinter::PushText( float value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-
-void XMLPrinter::PushText( double value )
-{
- char buf[BUF_SIZE];
- XMLUtil::ToStr( value, buf, BUF_SIZE );
- PushText( buf, false );
-}
-
-
-void XMLPrinter::PushComment( const char* comment )
-{
- if ( _elementJustOpened ) {
- SealElement();
- }
- if ( _textDepth < 0 && !_firstElement && !_compactMode) {
- Print( "\n" );
- PrintSpace( _depth );
- }
- _firstElement = false;
- Print( "", comment );
-}
-
-
-void XMLPrinter::PushDeclaration( const char* value )
-{
- if ( _elementJustOpened ) {
- SealElement();
- }
- if ( _textDepth < 0 && !_firstElement && !_compactMode) {
- Print( "\n" );
- PrintSpace( _depth );
- }
- _firstElement = false;
- Print( "%s?>", value );
-}
-
-
-void XMLPrinter::PushUnknown( const char* value )
-{
- if ( _elementJustOpened ) {
- SealElement();
- }
- if ( _textDepth < 0 && !_firstElement && !_compactMode) {
- Print( "\n" );
- PrintSpace( _depth );
- }
- _firstElement = false;
- Print( "", value );
-}
-
-
-bool XMLPrinter::VisitEnter( const XMLDocument& doc )
-{
- _processEntities = doc.ProcessEntities();
- if ( doc.HasBOM() ) {
- PushHeader( true, false );
- }
- return true;
-}
-
-
-bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )
-{
- OpenElement( element.Name() );
- while ( attribute ) {
- PushAttribute( attribute->Name(), attribute->Value() );
- attribute = attribute->Next();
- }
- return true;
-}
-
-
-bool XMLPrinter::VisitExit( const XMLElement& )
-{
- CloseElement();
- return true;
-}
-
-
-bool XMLPrinter::Visit( const XMLText& text )
-{
- PushText( text.Value(), text.CData() );
- return true;
-}
-
-
-bool XMLPrinter::Visit( const XMLComment& comment )
-{
- PushComment( comment.Value() );
- return true;
-}
-
-bool XMLPrinter::Visit( const XMLDeclaration& declaration )
-{
- PushDeclaration( declaration.Value() );
- return true;
-}
-
-
-bool XMLPrinter::Visit( const XMLUnknown& unknown )
-{
- PushUnknown( unknown.Value() );
- return true;
-}
-
-} // namespace tinyxml2
-
diff --git a/cocos/2d/support/tinyxml2/tinyxml2.h b/cocos/2d/support/tinyxml2/tinyxml2.h
deleted file mode 100644
index eeffa1096f..0000000000
--- a/cocos/2d/support/tinyxml2/tinyxml2.h
+++ /dev/null
@@ -1,1914 +0,0 @@
-/*
-Original code by Lee Thomason (www.grinninglizard.com)
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any
-damages arising from the use of this software.
-
-Permission is granted to anyone to use this software for any
-purpose, including commercial applications, and to alter it and
-redistribute it freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must
-not claim that you wrote the original software. If you use this
-software in a product, an acknowledgment in the product documentation
-would be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and
-must not be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-*/
-
-#ifndef TINYXML2_INCLUDED
-#define TINYXML2_INCLUDED
-
-#include "platform/CCPlatformConfig.h"
-#include "platform/CCPlatformMacros.h"
-
-#if defined(ANDROID_NDK) || defined(__BORLANDC__) || (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY)
-# include
-# include
-# include
-# include
-# include
-# include
-#else
-# include
-# include
-# include
-# include
-# include
-# include
-#endif
-
-/*
- TODO: intern strings instead of allocation.
-*/
-/*
- gcc:
- g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
-
- Formatting, Artistic Style:
- AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
-*/
-
-#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
-# ifndef DEBUG
-# define DEBUG
-# endif
-#endif
-
-
-#if defined(DEBUG)
-# if defined(_MSC_VER)
-# define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
-# elif defined (ANDROID_NDK)
-# include
-# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
-# else
-# include
-# define TIXMLASSERT assert
-# endif
-# else
-# define TIXMLASSERT( x ) {}
-#endif
-
-
-#if (defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE))
-// Microsoft visual studio, version 2005 and higher.
-/*int _snprintf_s(
- char *buffer,
- size_t sizeOfBuffer,
- size_t count,
- const char *format [,
- argument] ...
-);*/
-inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
-{
- va_list va;
- va_start( va, format );
- int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
- va_end( va );
- return result;
-}
-#define TIXML_SSCANF sscanf_s
-#else
-// GCC version 3 and higher
-//#warning( "Using sn* functions." )
-#define TIXML_SNPRINTF snprintf
-#define TIXML_SSCANF sscanf
-#endif
-
-static const int TIXML2_MAJOR_VERSION = 1;
-static const int TIXML2_MINOR_VERSION = 0;
-static const int TIXML2_PATCH_VERSION = 9;
-
-namespace tinyxml2
-{
-class XMLDocument;
-class XMLElement;
-class XMLAttribute;
-class XMLComment;
-class XMLNode;
-class XMLText;
-class XMLDeclaration;
-class XMLUnknown;
-
-class XMLPrinter;
-
-/*
- A class that wraps strings. Normally stores the start and end
- pointers into the XML file itself, and will apply normalization
- and entity translation if actually read. Can also store (and memory
- manage) a traditional char[]
-*/
-class CC_DLL StrPair
-{
-public:
- enum {
- NEEDS_ENTITY_PROCESSING = 0x01,
- NEEDS_NEWLINE_NORMALIZATION = 0x02,
- COLLAPSE_WHITESPACE = 0x04,
-
- TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
- TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
- ATTRIBUTE_NAME = 0,
- ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
- ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
- COMMENT = NEEDS_NEWLINE_NORMALIZATION
- };
-
- StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {}
- ~StrPair();
-
- void Set( char* start, char* end, int flags ) {
- Reset();
- _start = start;
- _end = end;
- _flags = flags | NEEDS_FLUSH;
- }
-
- const char* GetStr();
-
- bool Empty() const {
- return _start == _end;
- }
-
- void SetInternedStr( const char* str ) {
- Reset();
- _start = const_cast(str);
- }
-
- void SetStr( const char* str, int flags=0 );
-
- char* ParseText( char* in, const char* endTag, int strFlags );
- char* ParseName( char* in );
-
-private:
- void Reset();
- void CollapseWhitespace();
-
- enum {
- NEEDS_FLUSH = 0x100,
- NEEDS_DELETE = 0x200
- };
-
- // After parsing, if *end != 0, it can be set to zero.
- int _flags;
- char* _start;
- char* _end;
-};
-
-
-/*
- A dynamic array of Plain Old Data. Doesn't support constructors, etc.
- Has a small initial memory pool, so that low or no usage will not
- cause a call to new/delete
-*/
-template
-class CC_DLL DynArray
-{
-public:
- DynArray< T, INIT >() {
- _mem = _pool;
- _allocated = INIT;
- _size = 0;
- }
-
- ~DynArray() {
- if ( _mem != _pool ) {
- delete [] _mem;
- }
- }
-
- void Push( T t ) {
- EnsureCapacity( _size+1 );
- _mem[_size++] = t;
- }
-
- T* PushArr( int count ) {
- EnsureCapacity( _size+count );
- T* ret = &_mem[_size];
- _size += count;
- return ret;
- }
-
- T Pop() {
- return _mem[--_size];
- }
-
- void PopArr( int count ) {
- TIXMLASSERT( _size >= count );
- _size -= count;
- }
-
- bool Empty() const {
- return _size == 0;
- }
-
- T& operator[](int i) {
- TIXMLASSERT( i>= 0 && i < _size );
- return _mem[i];
- }
-
- const T& operator[](int i) const {
- TIXMLASSERT( i>= 0 && i < _size );
- return _mem[i];
- }
-
- int Size() const {
- return _size;
- }
-
- int Capacity() const {
- return _allocated;
- }
-
- const T* Mem() const {
- return _mem;
- }
-
- T* Mem() {
- return _mem;
- }
-
-private:
- void EnsureCapacity( int cap ) {
- if ( cap > _allocated ) {
- int newAllocated = cap * 2;
- T* newMem = new T[newAllocated];
- memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
- if ( _mem != _pool ) {
- delete [] _mem;
- }
- _mem = newMem;
- _allocated = newAllocated;
- }
- }
-
- T* _mem;
- T _pool[INIT];
- int _allocated; // objects allocated
- int _size; // number objects in use
-};
-
-
-/*
- Parent virtual class of a pool for fast allocation
- and deallocation of objects.
-*/
-class CC_DLL MemPool
-{
-public:
- MemPool() {}
- virtual ~MemPool() {}
-
- virtual int ItemSize() const = 0;
- virtual void* Alloc() = 0;
- virtual void Free( void* ) = 0;
- virtual void SetTracked() = 0;
-};
-
-
-/*
- Template child class to create pools of the correct type.
-*/
-template< int SIZE >
-class CC_DLL MemPoolT : public MemPool
-{
-public:
- MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
- ~MemPoolT() {
- // Delete the blocks.
- for( int i=0; i<_blockPtrs.Size(); ++i ) {
- delete _blockPtrs[i];
- }
- }
-
- virtual int ItemSize() const {
- return SIZE;
- }
- int CurrentAllocs() const {
- return _currentAllocs;
- }
-
- virtual void* Alloc() {
- if ( !_root ) {
- // Need a new block.
- Block* block = new Block();
- _blockPtrs.Push( block );
-
- for( int i=0; ichunk[i].next = &block->chunk[i+1];
- }
- block->chunk[COUNT-1].next = 0;
- _root = block->chunk;
- }
- void* result = _root;
- _root = _root->next;
-
- ++_currentAllocs;
- if ( _currentAllocs > _maxAllocs ) {
- _maxAllocs = _currentAllocs;
- }
- _nAllocs++;
- _nUntracked++;
- return result;
- }
- virtual void Free( void* mem ) {
- if ( !mem ) {
- return;
- }
- --_currentAllocs;
- Chunk* chunk = (Chunk*)mem;
-#ifdef DEBUG
- memset( chunk, 0xfe, sizeof(Chunk) );
-#endif
- chunk->next = _root;
- _root = chunk;
- }
- void Trace( const char* name ) {
- printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
- name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() );
- }
-
- void SetTracked() {
- _nUntracked--;
- }
-
- int Untracked() const {
- return _nUntracked;
- }
-
- enum { COUNT = 1024/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
-
-private:
- union Chunk {
- Chunk* next;
- char mem[SIZE];
- };
- struct Block {
- Chunk chunk[COUNT];
- };
- DynArray< Block*, 10 > _blockPtrs;
- Chunk* _root;
-
- int _currentAllocs;
- int _nAllocs;
- int _maxAllocs;
- int _nUntracked;
-};
-
-
-
-/**
- Implements the interface to the "Visitor pattern" (see the Accept() method.)
- If you call the Accept() method, it requires being passed a XMLVisitor
- class to handle callbacks. For nodes that contain other nodes (Document, Element)
- you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs
- are simply called with Visit().
-
- If you return 'true' from a Visit method, recursive parsing will continue. If you return
- false, no children of this node or its sibilings will be visited.
-
- All flavors of Visit methods have a default implementation that returns 'true' (continue
- visiting). You need to only override methods that are interesting to you.
-
- Generally Accept() is called on the TiXmlDocument, although all nodes support visiting.
-
- You should never change the document from a callback.
-
- @sa XMLNode::Accept()
-*/
-class CC_DLL XMLVisitor
-{
-public:
- virtual ~XMLVisitor() {}
-
- /// Visit a document.
- virtual bool VisitEnter( const XMLDocument& /*doc*/ ) {
- return true;
- }
- /// Visit a document.
- virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
- return true;
- }
-
- /// Visit an element.
- virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) {
- return true;
- }
- /// Visit an element.
- virtual bool VisitExit( const XMLElement& /*element*/ ) {
- return true;
- }
-
- /// Visit a declaration.
- virtual bool Visit( const XMLDeclaration& /*declaration*/ ) {
- return true;
- }
- /// Visit a text node.
- virtual bool Visit( const XMLText& /*text*/ ) {
- return true;
- }
- /// Visit a comment node.
- virtual bool Visit( const XMLComment& /*comment*/ ) {
- return true;
- }
- /// Visit an unknown node.
- virtual bool Visit( const XMLUnknown& /*unknown*/ ) {
- return true;
- }
-};
-
-
-/*
- Utility functionality.
-*/
-class CC_DLL XMLUtil
-{
-public:
- // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
- // correct, but simple, and usually works.
- static const char* SkipWhiteSpace( const char* p ) {
- while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast(p) ) ) {
- ++p;
- }
- return p;
- }
- static char* SkipWhiteSpace( char* p ) {
- while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast(p) ) ) {
- ++p;
- }
- return p;
- }
- static bool IsWhiteSpace( char p ) {
- return !IsUTF8Continuation(p) && isspace( static_cast(p) );
- }
-
- inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
- int n = 0;
- if ( p == q ) {
- return true;
- }
- while( *p && *q && *p == *q && n(const_cast(this)->FirstChildElement( value ));
- }
-
- /// Get the last child node, or null if none exists.
- const XMLNode* LastChild() const {
- return _lastChild;
- }
-
- XMLNode* LastChild() {
- return const_cast(const_cast(this)->LastChild() );
- }
-
- /** Get the last child element or optionally the last child
- element with the specified name.
- */
- const XMLElement* LastChildElement( const char* value=0 ) const;
-
- XMLElement* LastChildElement( const char* value=0 ) {
- return const_cast(const_cast(this)->LastChildElement(value) );
- }
-
- /// Get the previous (left) sibling node of this node.
- const XMLNode* PreviousSibling() const {
- return _prev;
- }
-
- XMLNode* PreviousSibling() {
- return _prev;
- }
-
- /// Get the previous (left) sibling element of this node, with an opitionally supplied name.
- const XMLElement* PreviousSiblingElement( const char* value=0 ) const ;
-
- XMLElement* PreviousSiblingElement( const char* value=0 ) {
- return const_cast(const_cast(this)->PreviousSiblingElement( value ) );
- }
-
- /// Get the next (right) sibling node of this node.
- const XMLNode* NextSibling() const {
- return _next;
- }
-
- XMLNode* NextSibling() {
- return _next;
- }
-
- /// Get the next (right) sibling element of this node, with an opitionally supplied name.
- const XMLElement* NextSiblingElement( const char* value=0 ) const;
-
- XMLElement* NextSiblingElement( const char* value=0 ) {
- return const_cast(const_cast(this)->NextSiblingElement( value ) );
- }
-
- /**
- Add a child node as the last (right) child.
- */
- XMLNode* InsertEndChild( XMLNode* addThis );
-
- XMLNode* LinkEndChild( XMLNode* addThis ) {
- return InsertEndChild( addThis );
- }
- /**
- Add a child node as the first (left) child.
- */
- XMLNode* InsertFirstChild( XMLNode* addThis );
- /**
- Add a node after the specified child node.
- */
- XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
-
- /**
- Delete all the children of this node.
- */
- void DeleteChildren();
-
- /**
- Delete a child of this node.
- */
- void DeleteChild( XMLNode* node );
-
- /**
- Make a copy of this node, but not its children.
- You may pass in a Document pointer that will be
- the owner of the new Node. If the 'document' is
- null, then the node returned will be allocated
- from the current Document. (this->GetDocument())
-
- Note: if called on a XMLDocument, this will return null.
- */
- virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0;
-
- /**
- Test if 2 nodes are the same, but don't test children.
- The 2 nodes do not need to be in the same Document.
-
- Note: if called on a XMLDocument, this will return false.
- */
- virtual bool ShallowEqual( const XMLNode* compare ) const = 0;
-
- /** Accept a hierarchical visit of the nodes in the TinyXML DOM. Every node in the
- XML tree will be conditionally visited and the host will be called back
- via the TiXmlVisitor interface.
-
- This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse
- the XML for the callbacks, so the performance of TinyXML is unchanged by using this
- interface versus any other.)
-
- The interface has been based on ideas from:
-
- - http://www.saxproject.org/
- - http://c2.com/cgi/wiki?HierarchicalVisitorPattern
-
- Which are both good references for "visiting".
-
- An example of using Accept():
- @verbatim
- TiXmlPrinter printer;
- tinyxmlDoc.Accept( &printer );
- const char* xmlcstr = printer.CStr();
- @endverbatim
- */
- virtual bool Accept( XMLVisitor* visitor ) const = 0;
-
- // internal
- virtual char* ParseDeep( char*, StrPair* );
-
-protected:
- XMLNode( XMLDocument* );
- virtual ~XMLNode();
- XMLNode( const XMLNode& ); // not supported
- XMLNode& operator=( const XMLNode& ); // not supported
-
- XMLDocument* _document;
- XMLNode* _parent;
- mutable StrPair _value;
-
- XMLNode* _firstChild;
- XMLNode* _lastChild;
-
- XMLNode* _prev;
- XMLNode* _next;
-
-private:
- MemPool* _memPool;
- void Unlink( XMLNode* child );
-};
-
-
-/** XML text.
-
- Note that a text node can have child element nodes, for example:
- @verbatim
- This is bold
- @endverbatim
-
- A text node can have 2 ways to output the next. "normal" output
- and CDATA. It will default to the mode it was parsed from the XML file and
- you generally want to leave it alone, but you can change the output mode with
- SetCDATA() and query it with CDATA().
-*/
-class CC_DLL XMLText : public XMLNode
-{
- friend class XMLBase;
- friend class XMLDocument;
-public:
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- virtual XMLText* ToText() {
- return this;
- }
- virtual const XMLText* ToText() const {
- return this;
- }
-
- /// Declare whether this should be CDATA or standard text.
- void SetCData( bool isCData ) {
- _isCData = isCData;
- }
- /// Returns true if this is a CDATA text element.
- bool CData() const {
- return _isCData;
- }
-
- char* ParseDeep( char*, StrPair* endTag );
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;
- virtual bool ShallowEqual( const XMLNode* compare ) const;
-
-protected:
- XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
- virtual ~XMLText() {}
- XMLText( const XMLText& ); // not supported
- XMLText& operator=( const XMLText& ); // not supported
-
-private:
- bool _isCData;
-};
-
-
-/** An XML Comment. */
-class CC_DLL XMLComment : public XMLNode
-{
- friend class XMLDocument;
-public:
- virtual XMLComment* ToComment() {
- return this;
- }
- virtual const XMLComment* ToComment() const {
- return this;
- }
-
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- char* ParseDeep( char*, StrPair* endTag );
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;
- virtual bool ShallowEqual( const XMLNode* compare ) const;
-
-protected:
- XMLComment( XMLDocument* doc );
- virtual ~XMLComment();
- XMLComment( const XMLComment& ); // not supported
- XMLComment& operator=( const XMLComment& ); // not supported
-
-private:
-};
-
-
-/** In correct XML the declaration is the first entry in the file.
- @verbatim
-
- @endverbatim
-
- TinyXML2 will happily read or write files without a declaration,
- however.
-
- The text of the declaration isn't interpreted. It is parsed
- and written as a string.
-*/
-class CC_DLL XMLDeclaration : public XMLNode
-{
- friend class XMLDocument;
-public:
- virtual XMLDeclaration* ToDeclaration() {
- return this;
- }
- virtual const XMLDeclaration* ToDeclaration() const {
- return this;
- }
-
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- char* ParseDeep( char*, StrPair* endTag );
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;
- virtual bool ShallowEqual( const XMLNode* compare ) const;
-
-protected:
- XMLDeclaration( XMLDocument* doc );
- virtual ~XMLDeclaration();
- XMLDeclaration( const XMLDeclaration& ); // not supported
- XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
-};
-
-
-/** Any tag that tinyXml doesn't recognize is saved as an
- unknown. It is a tag of text, but should not be modified.
- It will be written back to the XML, unchanged, when the file
- is saved.
-
- DTD tags get thrown into TiXmlUnknowns.
-*/
-class CC_DLL XMLUnknown : public XMLNode
-{
- friend class XMLDocument;
-public:
- virtual XMLUnknown* ToUnknown() {
- return this;
- }
- virtual const XMLUnknown* ToUnknown() const {
- return this;
- }
-
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- char* ParseDeep( char*, StrPair* endTag );
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;
- virtual bool ShallowEqual( const XMLNode* compare ) const;
-
-protected:
- XMLUnknown( XMLDocument* doc );
- virtual ~XMLUnknown();
- XMLUnknown( const XMLUnknown& ); // not supported
- XMLUnknown& operator=( const XMLUnknown& ); // not supported
-};
-
-
-enum XMLError {
- XML_NO_ERROR = 0,
- XML_SUCCESS = 0,
-
- XML_NO_ATTRIBUTE,
- XML_WRONG_ATTRIBUTE_TYPE,
-
- XML_ERROR_FILE_NOT_FOUND,
- XML_ERROR_FILE_COULD_NOT_BE_OPENED,
- XML_ERROR_FILE_READ_ERROR,
- XML_ERROR_ELEMENT_MISMATCH,
- XML_ERROR_PARSING_ELEMENT,
- XML_ERROR_PARSING_ATTRIBUTE,
- XML_ERROR_IDENTIFYING_TAG,
- XML_ERROR_PARSING_TEXT,
- XML_ERROR_PARSING_CDATA,
- XML_ERROR_PARSING_COMMENT,
- XML_ERROR_PARSING_DECLARATION,
- XML_ERROR_PARSING_UNKNOWN,
- XML_ERROR_EMPTY_DOCUMENT,
- XML_ERROR_MISMATCHED_ELEMENT,
- XML_ERROR_PARSING,
-
- XML_CAN_NOT_CONVERT_TEXT,
- XML_NO_TEXT_NODE
-};
-
-
-/** An attribute is a name-value pair. Elements have an arbitrary
- number of attributes, each with a unique name.
-
- @note The attributes are not XMLNodes. You may only query the
- Next() attribute in a list.
-*/
-class CC_DLL XMLAttribute
-{
- friend class XMLElement;
-public:
- /// The name of the attribute.
- const char* Name() const {
- return _name.GetStr();
- }
- /// The value of the attribute.
- const char* Value() const {
- return _value.GetStr();
- }
- /// The next attribute in the list.
- const XMLAttribute* Next() const {
- return _next;
- }
-
- /** IntAttribute interprets the attribute as an integer, and returns the value.
- If the value isn't an integer, 0 will be returned. There is no error checking;
- use QueryIntAttribute() if you need error checking.
- */
- int IntValue() const {
- int i=0;
- QueryIntValue( &i );
- return i;
- }
- /// Query as an unsigned integer. See IntAttribute()
- unsigned UnsignedValue() const {
- unsigned i=0;
- QueryUnsignedValue( &i );
- return i;
- }
- /// Query as a boolean. See IntAttribute()
- bool BoolValue() const {
- bool b=false;
- QueryBoolValue( &b );
- return b;
- }
- /// Query as a double. See IntAttribute()
- double DoubleValue() const {
- double d=0;
- QueryDoubleValue( &d );
- return d;
- }
- /// Query as a float. See IntAttribute()
- float FloatValue() const {
- float f=0;
- QueryFloatValue( &f );
- return f;
- }
-
- /** QueryIntAttribute interprets the attribute as an integer, and returns the value
- in the provided paremeter. The function will return XML_NO_ERROR on success,
- and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful.
- */
- XMLError QueryIntValue( int* value ) const;
- /// See QueryIntAttribute
- XMLError QueryUnsignedValue( unsigned int* value ) const;
- /// See QueryIntAttribute
- XMLError QueryBoolValue( bool* value ) const;
- /// See QueryIntAttribute
- XMLError QueryDoubleValue( double* value ) const;
- /// See QueryIntAttribute
- XMLError QueryFloatValue( float* value ) const;
-
- /// Set the attribute to a string value.
- void SetAttribute( const char* value );
- /// Set the attribute to value.
- void SetAttribute( int value );
- /// Set the attribute to value.
- void SetAttribute( unsigned value );
- /// Set the attribute to value.
- void SetAttribute( bool value );
- /// Set the attribute to value.
- void SetAttribute( double value );
- /// Set the attribute to value.
- void SetAttribute( float value );
-
-private:
- enum { BUF_SIZE = 200 };
-
- XMLAttribute() : _next( 0 ) {}
- virtual ~XMLAttribute() {}
-
- XMLAttribute( const XMLAttribute& ); // not supported
- void operator=( const XMLAttribute& ); // not supported
- void SetName( const char* name );
-
- char* ParseDeep( char* p, bool processEntities );
-
- mutable StrPair _name;
- mutable StrPair _value;
- XMLAttribute* _next;
- MemPool* _memPool;
-};
-
-
-/** The element is a container class. It has a value, the element name,
- and can contain other elements, text, comments, and unknowns.
- Elements also contain an arbitrary number of attributes.
-*/
-class CC_DLL XMLElement : public XMLNode
-{
- friend class XMLBase;
- friend class XMLDocument;
-public:
- /// Get the name of an element (which is the Value() of the node.)
- const char* Name() const {
- return Value();
- }
- /// Set the name of the element.
- void SetName( const char* str, bool staticMem=false ) {
- SetValue( str, staticMem );
- }
-
- virtual XMLElement* ToElement() {
- return this;
- }
- virtual const XMLElement* ToElement() const {
- return this;
- }
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- /** Given an attribute name, Attribute() returns the value
- for the attribute of that name, or null if none
- exists. For example:
-
- @verbatim
- const char* value = ele->Attribute( "foo" );
- @endverbatim
-
- The 'value' parameter is normally null. However, if specified,
- the attribute will only be returned if the 'name' and 'value'
- match. This allow you to write code:
-
- @verbatim
- if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar();
- @endverbatim
-
- rather than:
- @verbatim
- if ( ele->Attribute( "foo" ) ) {
- if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar();
- }
- @endverbatim
- */
- const char* Attribute( const char* name, const char* value=0 ) const;
-
- /** Given an attribute name, IntAttribute() returns the value
- of the attribute interpreted as an integer. 0 will be
- returned if there is an error. For a method with error
- checking, see QueryIntAttribute()
- */
- int IntAttribute( const char* name ) const {
- int i=0;
- QueryIntAttribute( name, &i );
- return i;
- }
- /// See IntAttribute()
- unsigned UnsignedAttribute( const char* name ) const {
- unsigned i=0;
- QueryUnsignedAttribute( name, &i );
- return i;
- }
- /// See IntAttribute()
- bool BoolAttribute( const char* name ) const {
- bool b=false;
- QueryBoolAttribute( name, &b );
- return b;
- }
- /// See IntAttribute()
- double DoubleAttribute( const char* name ) const {
- double d=0;
- QueryDoubleAttribute( name, &d );
- return d;
- }
- /// See IntAttribute()
- float FloatAttribute( const char* name ) const {
- float f=0;
- QueryFloatAttribute( name, &f );
- return f;
- }
-
- /** Given an attribute name, QueryIntAttribute() returns
- XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion
- can't be performed, or XML_NO_ATTRIBUTE if the attribute
- doesn't exist. If successful, the result of the conversion
- will be written to 'value'. If not successful, nothing will
- be written to 'value'. This allows you to provide default
- value:
-
- @verbatim
- int value = 10;
- QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10
- @endverbatim
- */
- XMLError QueryIntAttribute( const char* name, int* value ) const {
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryIntValue( value );
- }
- /// See QueryIntAttribute()
- XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryUnsignedValue( value );
- }
- /// See QueryIntAttribute()
- XMLError QueryBoolAttribute( const char* name, bool* value ) const {
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryBoolValue( value );
- }
- /// See QueryIntAttribute()
- XMLError QueryDoubleAttribute( const char* name, double* value ) const {
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryDoubleValue( value );
- }
- /// See QueryIntAttribute()
- XMLError QueryFloatAttribute( const char* name, float* value ) const {
- const XMLAttribute* a = FindAttribute( name );
- if ( !a ) {
- return XML_NO_ATTRIBUTE;
- }
- return a->QueryFloatValue( value );
- }
-
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, const char* value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, int value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, unsigned value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, bool value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
- /// Sets the named attribute to value.
- void SetAttribute( const char* name, double value ) {
- XMLAttribute* a = FindOrCreateAttribute( name );
- a->SetAttribute( value );
- }
-
- /**
- Delete an attribute.
- */
- void DeleteAttribute( const char* name );
-
- /// Return the first attribute in the list.
- const XMLAttribute* FirstAttribute() const {
- return _rootAttribute;
- }
- /// Query a specific attribute in the list.
- const XMLAttribute* FindAttribute( const char* name ) const;
-
- /** Convenience function for easy access to the text inside an element. Although easy
- and concise, GetText() is limited compared to getting the TiXmlText child
- and accessing it directly.
-
- If the first child of 'this' is a TiXmlText, the GetText()
- returns the character string of the Text node, else null is returned.
-
- This is a convenient method for getting the text of simple contained text:
- @verbatim
- This is text
- const char* str = fooElement->GetText();
- @endverbatim
-
- 'str' will be a pointer to "This is text".
-
- Note that this function can be misleading. If the element foo was created from
- this XML:
- @verbatim
- This is text
- @endverbatim
-
- then the value of str would be null. The first child node isn't a text node, it is
- another element. From this XML:
- @verbatim
- This is text
- @endverbatim
- GetText() will return "This is ".
- */
- const char* GetText() const;
-
- /**
- Convenience method to query the value of a child text node. This is probably best
- shown by example. Given you have a document is this form:
- @verbatim
-
- 1
- 1.4
-
- @endverbatim
-
- The QueryIntText() and similar functions provide a safe and easier way to get to the
- "value" of x and y.
-
- @verbatim
- int x = 0;
- float y = 0; // types of x and y are contrived for example
- const XMLElement* xElement = pointElement->FirstChildElement( "x" );
- const XMLElement* yElement = pointElement->FirstChildElement( "y" );
- xElement->QueryIntText( &x );
- yElement->QueryFloatText( &y );
- @endverbatim
-
- @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted
- to the requested type, and XML_NO_TEXT_NODE if there is no child text to query.
-
- */
- XMLError QueryIntText( int* ival ) const;
- /// See QueryIntText()
- XMLError QueryUnsignedText( unsigned* uval ) const;
- /// See QueryIntText()
- XMLError QueryBoolText( bool* bval ) const;
- /// See QueryIntText()
- XMLError QueryDoubleText( double* dval ) const;
- /// See QueryIntText()
- XMLError QueryFloatText( float* fval ) const;
-
- // internal:
- enum {
- OPEN, //
- CLOSED, //
- CLOSING //
- };
- int ClosingType() const {
- return _closingType;
- }
- char* ParseDeep( char* p, StrPair* endTag );
- virtual XMLNode* ShallowClone( XMLDocument* document ) const;
- virtual bool ShallowEqual( const XMLNode* compare ) const;
-
-private:
- XMLElement( XMLDocument* doc );
- virtual ~XMLElement();
- XMLElement( const XMLElement& ); // not supported
- void operator=( const XMLElement& ); // not supported
-
- XMLAttribute* FindAttribute( const char* name );
- XMLAttribute* FindOrCreateAttribute( const char* name );
- //void LinkAttribute( XMLAttribute* attrib );
- char* ParseAttributes( char* p );
-
- int _closingType;
- // The attribute list is ordered; there is no 'lastAttribute'
- // because the list needs to be scanned for dupes before adding
- // a new attribute.
- XMLAttribute* _rootAttribute;
-};
-
-
-enum Whitespace {
- PRESERVE_WHITESPACE,
- COLLAPSE_WHITESPACE
-};
-
-
-/** A Document binds together all the functionality.
- It can be saved, loaded, and printed to the screen.
- All Nodes are connected and allocated to a Document.
- If the Document is deleted, all its Nodes are also deleted.
-*/
-class CC_DLL XMLDocument : public XMLNode
-{
- friend class XMLElement;
-public:
- /// constructor
- XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE );
- ~XMLDocument();
-
- virtual XMLDocument* ToDocument() {
- return this;
- }
- virtual const XMLDocument* ToDocument() const {
- return this;
- }
-
- /**
- Parse an XML file from a character string.
- Returns XML_NO_ERROR (0) on success, or
- an errorID.
-
- You may optionally pass in the 'nBytes', which is
- the number of bytes which will be parsed. If not
- specified, TinyXML will assume 'xml' points to a
- null terminated string.
- */
- XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );
-
- /**
- Load an XML file from disk.
- Returns XML_NO_ERROR (0) on success, or
- an errorID.
- */
- XMLError LoadFile( const char* filename );
-
- /**
- Load an XML file from disk. You are responsible
- for providing and closing the FILE*.
-
- Returns XML_NO_ERROR (0) on success, or
- an errorID.
- */
- XMLError LoadFile( FILE* );
-
- /**
- Save the XML file to disk.
- Returns XML_NO_ERROR (0) on success, or
- an errorID.
- */
- XMLError SaveFile( const char* filename, bool compact = false );
-
- /**
- Save the XML file to disk. You are responsible
- for providing and closing the FILE*.
-
- Returns XML_NO_ERROR (0) on success, or
- an errorID.
- */
- XMLError SaveFile( FILE* fp, bool compact = false );
-
- bool ProcessEntities() const {
- return _processEntities;
- }
- Whitespace WhitespaceMode() const {
- return _whitespace;
- }
-
- /**
- Returns true if this document has a leading Byte Order Mark of UTF8.
- */
- bool HasBOM() const {
- return _writeBOM;
- }
- /** Sets whether to write the BOM when writing the file.
- */
- void SetBOM( bool useBOM ) {
- _writeBOM = useBOM;
- }
-
- /** Return the root element of DOM. Equivalent to FirstChildElement().
- To get the first node, use FirstChild().
- */
- XMLElement* RootElement() {
- return FirstChildElement();
- }
- const XMLElement* RootElement() const {
- return FirstChildElement();
- }
-
- /** Print the Document. If the Printer is not provided, it will
- print to stdout. If you provide Printer, this can print to a file:
- @verbatim
- XMLPrinter printer( fp );
- doc.Print( &printer );
- @endverbatim
-
- Or you can use a printer to print to memory:
- @verbatim
- XMLPrinter printer;
- doc->Print( &printer );
- // printer.CStr() has a const char* to the XML
- @endverbatim
- */
- void Print( XMLPrinter* streamer=0 );
- virtual bool Accept( XMLVisitor* visitor ) const;
-
- /**
- Create a new Element associated with
- this Document. The memory for the Element
- is managed by the Document.
- */
- XMLElement* NewElement( const char* name );
- /**
- Create a new Comment associated with
- this Document. The memory for the Comment
- is managed by the Document.
- */
- XMLComment* NewComment( const char* comment );
- /**
- Create a new Text associated with
- this Document. The memory for the Text
- is managed by the Document.
- */
- XMLText* NewText( const char* text );
- /**
- Create a new Declaration associated with
- this Document. The memory for the object
- is managed by the Document.
-
- If the 'text' param is null, the standard
- declaration is used.:
- @verbatim
-
- @endverbatim
- */
- XMLDeclaration* NewDeclaration( const char* text=0 );
- /**
- Create a new Unknown associated with
- this Document. The memory forthe object
- is managed by the Document.
- */
- XMLUnknown* NewUnknown( const char* text );
-
- /**
- Delete a node associated with this document.
- It will be unlinked from the DOM.
- */
- void DeleteNode( XMLNode* node ) {
- node->_parent->DeleteChild( node );
- }
-
- void SetError( XMLError error, const char* str1, const char* str2 );
-
- /// Return true if there was an error parsing the document.
- bool Error() const {
- return _errorID != XML_NO_ERROR;
- }
- /// Return the errorID.
- XMLError ErrorID() const {
- return _errorID;
- }
- /// Return a possibly helpful diagnostic location or string.
- const char* GetErrorStr1() const {
- return _errorStr1;
- }
- /// Return a possibly helpful secondary diagnostic location or string.
- const char* GetErrorStr2() const {
- return _errorStr2;
- }
- /// If there is an error, print it to stdout.
- void PrintError() const;
-
- // internal
- char* Identify( char* p, XMLNode** node );
-
- virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
- return 0;
- }
- virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {
- return false;
- }
-
-private:
- XMLDocument( const XMLDocument& ); // not supported
- void operator=( const XMLDocument& ); // not supported
- void InitDocument();
-
- bool _writeBOM;
- bool _processEntities;
- XMLError _errorID;
- Whitespace _whitespace;
- const char* _errorStr1;
- const char* _errorStr2;
- char* _charBuffer;
-
- MemPoolT< sizeof(XMLElement) > _elementPool;
- MemPoolT< sizeof(XMLAttribute) > _attributePool;
- MemPoolT< sizeof(XMLText) > _textPool;
- MemPoolT< sizeof(XMLComment) > _commentPool;
-};
-
-
-/**
- A XMLHandle is a class that wraps a node pointer with null checks; this is
- an incredibly useful thing. Note that XMLHandle is not part of the TinyXML
- DOM structure. It is a separate utility class.
-
- Take an example:
- @verbatim
-
-
-
-
-
-
- @endverbatim
-
- Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
- easy to write a *lot* of code that looks like:
-
- @verbatim
- XMLElement* root = document.FirstChildElement( "Document" );
- if ( root )
- {
- XMLElement* element = root->FirstChildElement( "Element" );
- if ( element )
- {
- XMLElement* child = element->FirstChildElement( "Child" );
- if ( child )
- {
- XMLElement* child2 = child->NextSiblingElement( "Child" );
- if ( child2 )
- {
- // Finally do something useful.
- @endverbatim
-
- And that doesn't even cover "else" cases. XMLHandle addresses the verbosity
- of such code. A XMLHandle checks for null pointers so it is perfectly safe
- and correct to use:
-
- @verbatim
- XMLHandle docHandle( &document );
- XMLElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement();
- if ( child2 )
- {
- // do something useful
- @endverbatim
-
- Which is MUCH more concise and useful.
-
- It is also safe to copy handles - internally they are nothing more than node pointers.
- @verbatim
- XMLHandle handleCopy = handle;
- @endverbatim
-
- See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects.
-*/
-class CC_DLL XMLHandle
-{
-public:
- /// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
- XMLHandle( XMLNode* node ) {
- _node = node;
- }
- /// Create a handle from a node.
- XMLHandle( XMLNode& node ) {
- _node = &node;
- }
- /// Copy constructor
- XMLHandle( const XMLHandle& ref ) {
- _node = ref._node;
- }
- /// Assignment
- XMLHandle& operator=( const XMLHandle& ref ) {
- _node = ref._node;
- return *this;
- }
-
- /// Get the first child of this handle.
- XMLHandle FirstChild() {
- return XMLHandle( _node ? _node->FirstChild() : 0 );
- }
- /// Get the first child element of this handle.
- XMLHandle FirstChildElement( const char* value=0 ) {
- return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 );
- }
- /// Get the last child of this handle.
- XMLHandle LastChild() {
- return XMLHandle( _node ? _node->LastChild() : 0 );
- }
- /// Get the last child element of this handle.
- XMLHandle LastChildElement( const char* _value=0 ) {
- return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 );
- }
- /// Get the previous sibling of this handle.
- XMLHandle PreviousSibling() {
- return XMLHandle( _node ? _node->PreviousSibling() : 0 );
- }
- /// Get the previous sibling element of this handle.
- XMLHandle PreviousSiblingElement( const char* _value=0 ) {
- return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
- }
- /// Get the next sibling of this handle.
- XMLHandle NextSibling() {
- return XMLHandle( _node ? _node->NextSibling() : 0 );
- }
- /// Get the next sibling element of this handle.
- XMLHandle NextSiblingElement( const char* _value=0 ) {
- return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
- }
-
- /// Safe cast to XMLNode. This can return null.
- XMLNode* ToNode() {
- return _node;
- }
- /// Safe cast to XMLElement. This can return null.
- XMLElement* ToElement() {
- return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
- }
- /// Safe cast to XMLText. This can return null.
- XMLText* ToText() {
- return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
- }
- /// Safe cast to XMLUnknown. This can return null.
- XMLUnknown* ToUnknown() {
- return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
- }
- /// Safe cast to XMLDeclaration. This can return null.
- XMLDeclaration* ToDeclaration() {
- return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
- }
-
-private:
- XMLNode* _node;
-};
-
-
-/**
- A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the
- same in all regards, except for the 'const' qualifiers. See XMLHandle for API.
-*/
-class CC_DLL XMLConstHandle
-{
-public:
- XMLConstHandle( const XMLNode* node ) {
- _node = node;
- }
- XMLConstHandle( const XMLNode& node ) {
- _node = &node;
- }
- XMLConstHandle( const XMLConstHandle& ref ) {
- _node = ref._node;
- }
-
- XMLConstHandle& operator=( const XMLConstHandle& ref ) {
- _node = ref._node;
- return *this;
- }
-
- const XMLConstHandle FirstChild() const {
- return XMLConstHandle( _node ? _node->FirstChild() : 0 );
- }
- const XMLConstHandle FirstChildElement( const char* value=0 ) const {
- return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 );
- }
- const XMLConstHandle LastChild() const {
- return XMLConstHandle( _node ? _node->LastChild() : 0 );
- }
- const XMLConstHandle LastChildElement( const char* _value=0 ) const {
- return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 );
- }
- const XMLConstHandle PreviousSibling() const {
- return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
- }
- const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const {
- return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
- }
- const XMLConstHandle NextSibling() const {
- return XMLConstHandle( _node ? _node->NextSibling() : 0 );
- }
- const XMLConstHandle NextSiblingElement( const char* _value=0 ) const {
- return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
- }
-
-
- const XMLNode* ToNode() const {
- return _node;
- }
- const XMLElement* ToElement() const {
- return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
- }
- const XMLText* ToText() const {
- return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
- }
- const XMLUnknown* ToUnknown() const {
- return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
- }
- const XMLDeclaration* ToDeclaration() const {
- return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
- }
-
-private:
- const XMLNode* _node;
-};
-
-
-/**
- Printing functionality. The XMLPrinter gives you more
- options than the XMLDocument::Print() method.
-
- It can:
- -# Print to memory.
- -# Print to a file you provide.
- -# Print XML without a XMLDocument.
-
- Print to Memory
-
- @verbatim
- XMLPrinter printer;
- doc->Print( &printer );
- SomeFunction( printer.CStr() );
- @endverbatim
-
- Print to a File
-
- You provide the file pointer.
- @verbatim
- XMLPrinter printer( fp );
- doc.Print( &printer );
- @endverbatim
-
- Print without a XMLDocument
-
- When loading, an XML parser is very useful. However, sometimes
- when saving, it just gets in the way. The code is often set up
- for streaming, and constructing the DOM is just overhead.
-
- The Printer supports the streaming case. The following code
- prints out a trivially simple XML file without ever creating
- an XML document.
-
- @verbatim
- XMLPrinter printer( fp );
- printer.OpenElement( "foo" );
- printer.PushAttribute( "foo", "bar" );
- printer.CloseElement();
- @endverbatim
-*/
-class CC_DLL XMLPrinter : public XMLVisitor
-{
-public:
- /** Construct the printer. If the FILE* is specified,
- this will print to the FILE. Else it will print
- to memory, and the result is available in CStr().
- If 'compact' is set to true, then output is created
- with only required whitespace and newlines.
- */
- XMLPrinter( FILE* file=0, bool compact = false );
- ~XMLPrinter() {}
-
- /** If streaming, write the BOM and declaration. */
- void PushHeader( bool writeBOM, bool writeDeclaration );
- /** If streaming, start writing an element.
- The element must be closed with CloseElement()
- */
- void OpenElement( const char* name );
- /// If streaming, add an attribute to an open element.
- void PushAttribute( const char* name, const char* value );
- void PushAttribute( const char* name, int value );
- void PushAttribute( const char* name, unsigned value );
- void PushAttribute( const char* name, bool value );
- void PushAttribute( const char* name, double value );
- /// If streaming, close the Element.
- void CloseElement();
-
- /// Add a text node.
- void PushText( const char* text, bool cdata=false );
- /// Add a text node from an integer.
- void PushText( int value );
- /// Add a text node from an unsigned.
- void PushText( unsigned value );
- /// Add a text node from a bool.
- void PushText( bool value );
- /// Add a text node from a float.
- void PushText( float value );
- /// Add a text node from a double.
- void PushText( double value );
-
- /// Add a comment
- void PushComment( const char* comment );
-
- void PushDeclaration( const char* value );
- void PushUnknown( const char* value );
-
- virtual bool VisitEnter( const XMLDocument& /*doc*/ );
- virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
- return true;
- }
-
- virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
- virtual bool VisitExit( const XMLElement& element );
-
- virtual bool Visit( const XMLText& text );
- virtual bool Visit( const XMLComment& comment );
- virtual bool Visit( const XMLDeclaration& declaration );
- virtual bool Visit( const XMLUnknown& unknown );
-
- /**
- If in print to memory mode, return a pointer to
- the XML file in memory.
- */
- const char* CStr() const {
- return _buffer.Mem();
- }
- /**
- If in print to memory mode, return the size
- of the XML file in memory. (Note the size returned
- includes the terminating null.)
- */
- int CStrSize() const {
- return _buffer.Size();
- }
-
-private:
- void SealElement();
- void PrintSpace( int depth );
- void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
- void Print( const char* format, ... );
-
- bool _elementJustOpened;
- bool _firstElement;
- FILE* _fp;
- int _depth;
- int _textDepth;
- bool _processEntities;
- bool _compactMode;
-
- enum {
- ENTITY_RANGE = 64,
- BUF_SIZE = 200
- };
- bool _entityFlag[ENTITY_RANGE];
- bool _restrictedEntityFlag[ENTITY_RANGE];
-
- DynArray< const char*, 10 > _stack;
- DynArray< char, 20 > _buffer;
-#ifdef _MSC_VER
- DynArray< char, 20 > _accumulator;
-#endif
-};
-
-
-} // tinyxml2
-
-
-#endif // TINYXML2_INCLUDED
diff --git a/cocos/2d/support/zip_support/ioapi.cpp b/cocos/2d/support/zip_support/ioapi.cpp
deleted file mode 100644
index 669ea36927..0000000000
--- a/cocos/2d/support/zip_support/ioapi.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-/* ioapi.h -- IO base function header for compress/uncompress .zip
- part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
- Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
- Modifications for Zip64 support
- Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
- For more info read MiniZip_info.txt
-
-*/
-
-#include "ioapi.h"
-
-namespace cocos2d {
-
-voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
-{
- if (pfilefunc->zfile_func64.zopen64_file != NULL)
- return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
- else
- {
- return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);
- }
-}
-
-long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
-{
- if (pfilefunc->zfile_func64.zseek64_file != NULL)
- return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
- else
- {
- uLong offsetTruncated = (uLong)offset;
- if (offsetTruncated != offset)
- return -1;
- else
- return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);
- }
-}
-
-ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
-{
- if (pfilefunc->zfile_func64.zseek64_file != NULL)
- return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
- else
- {
- uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
- if ((tell_uLong) == ((uLong)-1))
- return (ZPOS64_T)-1;
- else
- return tell_uLong;
- }
-}
-
-void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
-{
- p_filefunc64_32->zfile_func64.zopen64_file = NULL;
- p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
- p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
- p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
- p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
- p_filefunc64_32->zfile_func64.ztell64_file = NULL;
- p_filefunc64_32->zfile_func64.zseek64_file = NULL;
- p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
- p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
- p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
- p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
- p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
-}
-
-
-
-static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
-static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
-static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
-static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
-static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
-static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
-static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
-
-static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
-{
- FILE* file = NULL;
- const char* mode_fopen = NULL;
- if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
- mode_fopen = "rb";
- else
- if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
- mode_fopen = "r+b";
- else
- if (mode & ZLIB_FILEFUNC_MODE_CREATE)
- mode_fopen = "wb";
-
- if ((filename!=NULL) && (mode_fopen != NULL))
- file = fopen(filename, mode_fopen);
- return file;
-}
-
-static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
-{
- FILE* file = NULL;
- const char* mode_fopen = NULL;
- if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
- mode_fopen = "rb";
- else
- if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
- mode_fopen = "r+b";
- else
- if (mode & ZLIB_FILEFUNC_MODE_CREATE)
- mode_fopen = "wb";
-
- if ((filename!=NULL) && (mode_fopen != NULL))
- {
-#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA || CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_NACL || CC_TARGET_PLATFORM == CC_PLATFORM_EMSCRIPTEN)
- file = NULL;
-#else
- file = fopen64((const char*)filename, mode_fopen);
-#endif
- }
-
- return file;
-}
-
-
-static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
-{
- uLong ret;
- ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
- return ret;
-}
-
-static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
-{
- uLong ret;
- ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
- return ret;
-}
-
-static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
-{
- long ret;
- ret = ftell((FILE *)stream);
- return ret;
-}
-
-
-static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
-{
- ZPOS64_T ret;
-#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA || CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_NACL || CC_TARGET_PLATFORM == CC_PLATFORM_EMSCRIPTEN)
- ret = 0;
-#else
- ret = ftello64((FILE *)stream);
-#endif
- return ret;
-}
-
-static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
-{
- int fseek_origin=0;
- long ret;
- switch (origin)
- {
- case ZLIB_FILEFUNC_SEEK_CUR :
- fseek_origin = SEEK_CUR;
- break;
- case ZLIB_FILEFUNC_SEEK_END :
- fseek_origin = SEEK_END;
- break;
- case ZLIB_FILEFUNC_SEEK_SET :
- fseek_origin = SEEK_SET;
- break;
- default: return -1;
- }
- ret = 0;
- if (fseek((FILE *)stream, offset, fseek_origin) != 0)
- ret = -1;
- return ret;
-}
-
-static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
-{
-#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE || CC_TARGET_PLATFORM == CC_PLATFORM_BADA || CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_NACL || CC_TARGET_PLATFORM == CC_PLATFORM_EMSCRIPTEN)
- return -1;
-#else
- int fseek_origin=0;
- switch (origin)
- {
- case ZLIB_FILEFUNC_SEEK_CUR :
- fseek_origin = SEEK_CUR;
- break;
- case ZLIB_FILEFUNC_SEEK_END :
- fseek_origin = SEEK_END;
- break;
- case ZLIB_FILEFUNC_SEEK_SET :
- fseek_origin = SEEK_SET;
- break;
- default: return -1;
- }
- if(fseeko64((FILE *)stream, offset, fseek_origin) != 0)
- return -1;
- return 0;
-#endif
-}
-
-
-static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
-{
- int ret;
- ret = fclose((FILE *)stream);
- return ret;
-}
-
-static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
-{
- int ret;
- ret = ferror((FILE *)stream);
- return ret;
-}
-
-void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
-{
- pzlib_filefunc_def->zopen_file = fopen_file_func;
- pzlib_filefunc_def->zread_file = fread_file_func;
- pzlib_filefunc_def->zwrite_file = fwrite_file_func;
- pzlib_filefunc_def->ztell_file = ftell_file_func;
- pzlib_filefunc_def->zseek_file = fseek_file_func;
- pzlib_filefunc_def->zclose_file = fclose_file_func;
- pzlib_filefunc_def->zerror_file = ferror_file_func;
- pzlib_filefunc_def->opaque = NULL;
-}
-
-void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
-{
- pzlib_filefunc_def->zopen64_file = fopen64_file_func;
- pzlib_filefunc_def->zread_file = fread_file_func;
- pzlib_filefunc_def->zwrite_file = fwrite_file_func;
- pzlib_filefunc_def->ztell64_file = ftell64_file_func;
- pzlib_filefunc_def->zseek64_file = fseek64_file_func;
- pzlib_filefunc_def->zclose_file = fclose_file_func;
- pzlib_filefunc_def->zerror_file = ferror_file_func;
- pzlib_filefunc_def->opaque = NULL;
-}
-
-} // end of namespace cocos2d
diff --git a/cocos/2d/support/zip_support/ioapi.h b/cocos/2d/support/zip_support/ioapi.h
deleted file mode 100644
index 575f44ece4..0000000000
--- a/cocos/2d/support/zip_support/ioapi.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/* ioapi.h -- IO base function header for compress/uncompress .zip
- part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
- Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
- Modifications for Zip64 support
- Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
- For more info read MiniZip_info.txt
-
- Changes
-
- Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)
- Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.
- More if/def section may be needed to support other platforms
- Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.
- (but you should use iowin32.c for windows instead)
-
-*/
-
-#ifndef _ZLIBIOAPI64_H
-#define _ZLIBIOAPI64_H
-
-#include "platform/CCPlatformConfig.h"
-
-#if (!defined(_WIN32)) && (!defined(WIN32))
-
- // Linux needs this to support file operation on files larger then 4+GB
- // But might need better if/def to select just the platforms that needs them.
-
- #ifndef __USE_FILE_OFFSET64
- #define __USE_FILE_OFFSET64
- #endif
- #ifndef __USE_LARGEFILE64
- #define __USE_LARGEFILE64
- #endif
- #ifndef _LARGEFILE64_SOURCE
- #define _LARGEFILE64_SOURCE
- #endif
- #ifndef _FILE_OFFSET_BIT
- #define _FILE_OFFSET_BIT 64
- #endif
-#endif
-
-#include
-#include
-#include "zlib.h"
-
-namespace cocos2d {
-
-#ifndef OF
-#define OF _Z_OF
-#endif
-
-#if defined(USE_FILE32API)
-#define fopen64 fopen
-#define ftello64 ftell
-#define fseeko64 fseek
-#else
-#ifdef _MSC_VER
- #define fopen64 fopen
- #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
- #define ftello64 _ftelli64
- #define fseeko64 _fseeki64
- #else // old MSC
- #define ftello64 ftell
- #define fseeko64 fseek
- #endif
-#endif
-#endif
-
-/*
-#ifndef ZPOS64_T
- #ifdef _WIN32
- #define ZPOS64_T fpos_t
- #else
- #include
- #define ZPOS64_T uint64_t
- #endif
-#endif
-*/
-
-#ifdef HAVE_MINIZIP64_CONF_H
-#include "mz64conf.h"
-#endif
-
-/* a type chosen by DEFINE */
-#ifdef HAVE_64BIT_INT_CUSTOM
-typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
-#else
-#ifdef HAS_STDINT_H
-#include "stdint.h"
-typedef uint64_t ZPOS64_T;
-#else
-
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-typedef unsigned __int64 ZPOS64_T;
-#else
-typedef unsigned long long int ZPOS64_T;
-#endif
-#endif
-#endif
-
-
-
-#define ZLIB_FILEFUNC_SEEK_CUR (1)
-#define ZLIB_FILEFUNC_SEEK_END (2)
-#define ZLIB_FILEFUNC_SEEK_SET (0)
-
-#define ZLIB_FILEFUNC_MODE_READ (1)
-#define ZLIB_FILEFUNC_MODE_WRITE (2)
-#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
-
-#define ZLIB_FILEFUNC_MODE_EXISTING (4)
-#define ZLIB_FILEFUNC_MODE_CREATE (8)
-
-
-#ifndef ZCALLBACK
- #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
- #define ZCALLBACK CALLBACK
- #else
- #define ZCALLBACK
- #endif
-#endif
-
-
-
-
-typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
-typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
-typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
-typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
-typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
-
-typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
-typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
-
-
-/* here is the "old" 32 bits structure structure */
-typedef struct zlib_filefunc_def_s
-{
- open_file_func zopen_file;
- read_file_func zread_file;
- write_file_func zwrite_file;
- tell_file_func ztell_file;
- seek_file_func zseek_file;
- close_file_func zclose_file;
- testerror_file_func zerror_file;
- voidpf opaque;
-} zlib_filefunc_def;
-
-typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
-typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
-typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
-
-typedef struct zlib_filefunc64_def_s
-{
- open64_file_func zopen64_file;
- read_file_func zread_file;
- write_file_func zwrite_file;
- tell64_file_func ztell64_file;
- seek64_file_func zseek64_file;
- close_file_func zclose_file;
- testerror_file_func zerror_file;
- voidpf opaque;
-} zlib_filefunc64_def;
-
-void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
-void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
-
-/* now internal definition, only for zip.c and unzip.h */
-typedef struct zlib_filefunc64_32_def_s
-{
- zlib_filefunc64_def zfile_func64;
- open_file_func zopen32_file;
- tell_file_func ztell32_file;
- seek_file_func zseek32_file;
-} zlib_filefunc64_32_def;
-
-
-#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
-#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
-//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
-//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
-#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
-#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
-
-voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
-long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
-ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
-
-void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
-
-#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
-#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
-#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))
-
-} // end of namespace cocos2d
-
-#endif
diff --git a/cocos/2d/support/zip_support/unzip.cpp b/cocos/2d/support/zip_support/unzip.cpp
deleted file mode 100644
index 66cfeff16a..0000000000
--- a/cocos/2d/support/zip_support/unzip.cpp
+++ /dev/null
@@ -1,2161 +0,0 @@
-/* unzip.c -- IO for uncompress .zip files using zlib
- Version 1.1, February 14h, 2010
- part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
- Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
- Modifications of Unzip for Zip64
- Copyright (C) 2007-2008 Even Rouault
-
- Modifications for Zip64 support on both zip and unzip
- Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
- For more info read MiniZip_info.txt
-
-
- ------------------------------------------------------------------------------------
- Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
- compatibility with older software. The following is from the original crypt.c.
- Code woven in by Terry Thorsen 1/2003.
-
- Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
-
- See the accompanying file LICENSE, version 2000-Apr-09 or later
- (the contents of which are also included in zip.h) for terms of use.
- If, for some reason, all these files are missing, the Info-ZIP license
- also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
-
- crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h]
-
- The encryption/decryption parts of this source code (as opposed to the
- non-echoing password parts) were originally written in Europe. The
- whole source package can be freely distributed, including from the USA.
- (Prior to January 2000, re-export from the US was a violation of US law.)
-
- This encryption code is a direct transcription of the algorithm from
- Roger Schlafly, described by Phil Katz in the file appnote.txt. This
- file (appnote.txt) is distributed with the PKZIP program (even in the
- version without encryption capabilities).
-
- ------------------------------------------------------------------------------------
-
- Changes in unzip.c
-
- 2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos
- 2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz*
- 2007-2008 - Even Rouault - Remove old C style function prototypes
- 2007-2008 - Even Rouault - Add unzip support for ZIP64
-
- Copyright (C) 2007-2008 Even Rouault
-
-
- Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).
- Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G
- should only read the compressed/uncompressed size from the Zip64 format if
- the size from normal header was 0xFFFFFFFF
- Oct-2009 - Mathias Svensson - Applied some bug fixes from patches received from Gilles Vollant
- Oct-2009 - Mathias Svensson - Applied support to unzip files with compression method BZIP2 (bzip2 lib is required)
- Patch created by Daniel Borca
-
- Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer
-
- Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson
-
-*/
-
-
-#include
-#include
-#include
-
-#ifndef NOUNCRYPT
- #define NOUNCRYPT
-#endif
-
-#include "zlib.h"
-#include "unzip.h"
-
-#ifdef STDC
-# include
-# include
-# include
-#endif
-#ifdef NO_ERRNO_H
- extern int errno;
-#else
-# include
-#endif
-
-namespace cocos2d {
-
-#ifndef local
-# define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-
-#ifndef CASESENSITIVITYDEFAULT_NO
-# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
-# define CASESENSITIVITYDEFAULT_NO
-# endif
-#endif
-
-
-#ifndef UNZ_BUFSIZE
-#define UNZ_BUFSIZE (16384)
-#endif
-
-#ifndef UNZ_MAXFILENAMEINZIP
-#define UNZ_MAXFILENAMEINZIP (256)
-#endif
-
-#ifndef ALLOC
-# define ALLOC(size) (malloc(size))
-#endif
-#ifndef TRYFREE
-# define TRYFREE(p) {if (p) free(p);}
-#endif
-
-#define SIZECENTRALDIRITEM (0x2e)
-#define SIZEZIPLOCALHEADER (0x1e)
-
-
-const char unz_copyright[] =
- " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
-
-/* unz_file_info_interntal contain internal info about a file in zipfile*/
-typedef struct unz_file_info64_internal_s
-{
- ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */
-} unz_file_info64_internal;
-
-
-/* file_in_zip_read_info_s contain internal information about a file in zipfile,
- when reading and decompress it */
-typedef struct
-{
- char *read_buffer; /* internal buffer for compressed data */
- z_stream stream; /* zLib stream structure for inflate */
-
-#ifdef HAVE_BZIP2
- bz_stream bstream; /* bzLib stream structure for bziped */
-#endif
-
- ZPOS64_T pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
- uLong stream_initialised; /* flag set if stream structure is initialized*/
-
- ZPOS64_T offset_local_extrafield;/* offset of the local extra field */
- uInt size_local_extrafield;/* size of the local extra field */
- ZPOS64_T pos_local_extrafield; /* position in the local extra field in read*/
- ZPOS64_T total_out_64;
-
- uLong crc32; /* crc32 of all data uncompressed */
- uLong crc32_wait; /* crc32 we must obtain after decompress all */
- ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */
- ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/
- zlib_filefunc64_32_def z_filefunc;
- voidpf filestream; /* io structure of the zipfile */
- uLong compression_method; /* compression method (0==store) */
- ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
- int raw;
-} file_in_zip64_read_info_s;
-
-
-/* unz64_s contain internal information about the zipfile
-*/
-typedef struct
-{
- zlib_filefunc64_32_def z_filefunc;
- int is64bitOpenFunction;
- voidpf filestream; /* io structure of the zipfile */
- unz_global_info64 gi; /* public global information */
- ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
- ZPOS64_T num_file; /* number of the current file in the zipfile*/
- ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/
- ZPOS64_T current_file_ok; /* flag about the usability of the current file*/
- ZPOS64_T central_pos; /* position of the beginning of the central dir*/
-
- ZPOS64_T size_central_dir; /* size of the central directory */
- ZPOS64_T offset_central_dir; /* offset of start of central directory with
- respect to the starting disk number */
-
- unz_file_info64 cur_file_info; /* public info about the current file in zip*/
- unz_file_info64_internal cur_file_info_internal; /* private info about it*/
- file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current
- file if we are decompressing it */
- int encrypted;
-
- int isZip64;
-
-# ifndef NOUNCRYPT
- unsigned long keys[3]; /* keys defining the pseudo-random sequence */
- const unsigned long* pcrc_32_tab;
-# endif
-} unz64_s;
-
-
-#ifndef NOUNCRYPT
-#include "crypt.h"
-#endif
-
-/* ===========================================================================
- Read a byte from a gz_stream; update next_in and avail_in. Return EOF
- for end of file.
- IN assertion: the stream s has been successfully opened for reading.
-*/
-
-
-local int unz64local_getByte OF((
- const zlib_filefunc64_32_def* pzlib_filefunc_def,
- voidpf filestream,
- int *pi));
-
-local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)
-{
- unsigned char c;
- int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
- if (err==1)
- {
- *pi = (int)c;
- return UNZ_OK;
- }
- else
- {
- if (ZERROR64(*pzlib_filefunc_def,filestream))
- return UNZ_ERRNO;
- else
- return UNZ_EOF;
- }
-}
-
-
-/* ===========================================================================
- Reads a long in LSB order from the given gz_stream. Sets
-*/
-local int unz64local_getShort OF((
- const zlib_filefunc64_32_def* pzlib_filefunc_def,
- voidpf filestream,
- uLong *pX));
-
-local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
- voidpf filestream,
- uLong *pX)
-{
- uLong x ;
- int i = 0;
- int err;
-
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x = (uLong)i;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x |= ((uLong)i)<<8;
-
- if (err==UNZ_OK)
- *pX = x;
- else
- *pX = 0;
- return err;
-}
-
-local int unz64local_getLong OF((
- const zlib_filefunc64_32_def* pzlib_filefunc_def,
- voidpf filestream,
- uLong *pX));
-
-local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
- voidpf filestream,
- uLong *pX)
-{
- uLong x ;
- int i = 0;
- int err;
-
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x = (uLong)i;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x |= ((uLong)i)<<8;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x |= ((uLong)i)<<16;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x += ((uLong)i)<<24;
-
- if (err==UNZ_OK)
- *pX = x;
- else
- *pX = 0;
- return err;
-}
-
-local int unz64local_getLong64 OF((
- const zlib_filefunc64_32_def* pzlib_filefunc_def,
- voidpf filestream,
- ZPOS64_T *pX));
-
-
-local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
- voidpf filestream,
- ZPOS64_T *pX)
-{
- ZPOS64_T x ;
- int i = 0;
- int err;
-
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x = (ZPOS64_T)i;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x |= ((ZPOS64_T)i)<<8;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x |= ((ZPOS64_T)i)<<16;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x |= ((ZPOS64_T)i)<<24;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x |= ((ZPOS64_T)i)<<32;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x |= ((ZPOS64_T)i)<<40;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x |= ((ZPOS64_T)i)<<48;
-
- if (err==UNZ_OK)
- err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
- x |= ((ZPOS64_T)i)<<56;
-
- if (err==UNZ_OK)
- *pX = x;
- else
- *pX = 0;
- return err;
-}
-
-/* My own strcmpi / strcasecmp */
-local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2)
-{
- for (;;)
- {
- char c1=*(fileName1++);
- char c2=*(fileName2++);
- if ((c1>='a') && (c1<='z'))
- c1 -= 0x20;
- if ((c2>='a') && (c2<='z'))
- c2 -= 0x20;
- if (c1=='\0')
- return ((c2=='\0') ? 0 : -1);
- if (c2=='\0')
- return 1;
- if (c1c2)
- return 1;
- }
-}
-
-
-#ifdef CASESENSITIVITYDEFAULT_NO
-#define CASESENSITIVITYDEFAULTVALUE 2
-#else
-#define CASESENSITIVITYDEFAULTVALUE 1
-#endif
-
-#ifndef STRCMPCASENOSENTIVEFUNCTION
-#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
-#endif
-
-/*
- Compare two filename (fileName1,fileName2).
- If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp)
- If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi
- or strcasecmp)
- If iCaseSenisivity = 0, case sensitivity is default of your operating system
- (like 1 on Unix, 2 on Windows)
-
-*/
-int ZEXPORT unzStringFileNameCompare (const char* fileName1,
- const char* fileName2,
- int iCaseSensitivity)
-
-{
- if (iCaseSensitivity==0)
- iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
-
- if (iCaseSensitivity==1)
- return strcmp(fileName1,fileName2);
-
- return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
-}
-
-#ifndef BUFREADCOMMENT
-#define BUFREADCOMMENT (0x400)
-#endif
-
-/*
- Locate the Central directory of a zipfile (at the end, just before
- the global comment)
-*/
-local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
-local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
-{
- unsigned char* buf;
- ZPOS64_T uSizeFile;
- ZPOS64_T uBackRead;
- ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
- ZPOS64_T uPosFound=0;
-
- if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
- return 0;
-
-
- uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
-
- if (uMaxBack>uSizeFile)
- uMaxBack = uSizeFile;
-
- buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
- if (buf==NULL)
- return 0;
-
- uBackRead = 4;
- while (uBackReaduMaxBack)
- uBackRead = uMaxBack;
- else
- uBackRead+=BUFREADCOMMENT;
- uReadPos = uSizeFile-uBackRead ;
-
- uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
- (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
- if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
- break;
-
- if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
- break;
-
- for (i=(int)uReadSize-3; (i--)>0;)
- if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
- ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
- {
- uPosFound = uReadPos+i;
- break;
- }
-
- if (uPosFound!=0)
- break;
- }
- TRYFREE(buf);
- return uPosFound;
-}
-
-
-/*
- Locate the Central directory 64 of a zipfile (at the end, just before
- the global comment)
-*/
-local ZPOS64_T unz64local_SearchCentralDir64 OF((
- const zlib_filefunc64_32_def* pzlib_filefunc_def,
- voidpf filestream));
-
-local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
- voidpf filestream)
-{
- unsigned char* buf;
- ZPOS64_T uSizeFile;
- ZPOS64_T uBackRead;
- ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
- ZPOS64_T uPosFound=0;
- uLong uL;
- ZPOS64_T relativeOffset;
-
- if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
- return 0;
-
-
- uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
-
- if (uMaxBack>uSizeFile)
- uMaxBack = uSizeFile;
-
- buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
- if (buf==NULL)
- return 0;
-
- uBackRead = 4;
- while (uBackReaduMaxBack)
- uBackRead = uMaxBack;
- else
- uBackRead+=BUFREADCOMMENT;
- uReadPos = uSizeFile-uBackRead ;
-
- uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
- (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
- if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
- break;
-
- if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
- break;
-
- for (i=(int)uReadSize-3; (i--)>0;)
- if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
- ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
- {
- uPosFound = uReadPos+i;
- break;
- }
-
- if (uPosFound!=0)
- break;
- }
- TRYFREE(buf);
- if (uPosFound == 0)
- return 0;
-
- /* Zip64 end of central directory locator */
- if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
- return 0;
-
- /* the signature, already checked */
- if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
- return 0;
-
- /* number of the disk with the start of the zip64 end of central directory */
- if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
- return 0;
- if (uL != 0)
- return 0;
-
- /* relative offset of the zip64 end of central directory record */
- if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
- return 0;
-
- /* total number of disks */
- if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
- return 0;
- if (uL != 1)
- return 0;
-
- /* Goto end of central directory record */
- if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
- return 0;
-
- /* the signature */
- if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
- return 0;
-
- if (uL != 0x06064b50)
- return 0;
-
- return relativeOffset;
-}
-
-/*
- Open a Zip file. path contain the full pathname (by example,
- on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
- "zlib/zlib114.zip".
- If the zipfile cannot be opened (file doesn't exist or in not valid), the
- return value is NULL.
- Else, the return value is a unzFile Handle, usable with other function
- of this unzip package.
-*/
-local unzFile unzOpenInternal (const void *path,
- zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
- int is64bitOpenFunction)
-{
- unz64_s us;
- unz64_s *s;
- ZPOS64_T central_pos;
- uLong uL;
-
- uLong number_disk; /* number of the current dist, used for
- spanning ZIP, unsupported, always 0*/
- uLong number_disk_with_CD; /* number the the disk with central dir, used
- for spanning ZIP, unsupported, always 0*/
- ZPOS64_T number_entry_CD; /* total number of entries in
- the central dir
- (same than number_entry on nospan) */
-
- int err=UNZ_OK;
-
- if (unz_copyright[0]!=' ')
- return NULL;
-
- us.z_filefunc.zseek32_file = NULL;
- us.z_filefunc.ztell32_file = NULL;
- if (pzlib_filefunc64_32_def==NULL)
- fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);
- else
- us.z_filefunc = *pzlib_filefunc64_32_def;
- us.is64bitOpenFunction = is64bitOpenFunction;
-
-
-
- us.filestream = ZOPEN64(us.z_filefunc,
- path,
- ZLIB_FILEFUNC_MODE_READ |
- ZLIB_FILEFUNC_MODE_EXISTING);
- if (us.filestream==NULL)
- return NULL;
-
- central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
- if (central_pos)
- {
- uLong uS;
- ZPOS64_T uL64;
-
- us.isZip64 = 1;
-
- if (ZSEEK64(us.z_filefunc, us.filestream,
- central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
- err=UNZ_ERRNO;
-
- /* the signature, already checked */
- if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* size of zip64 end of central directory record */
- if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* version made by */
- if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* version needed to extract */
- if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* number of this disk */
- if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* number of the disk with the start of the central directory */
- if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* total number of entries in the central directory on this disk */
- if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* total number of entries in the central directory */
- if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- if ((number_entry_CD!=us.gi.number_entry) ||
- (number_disk_with_CD!=0) ||
- (number_disk!=0))
- err=UNZ_BADZIPFILE;
-
- /* size of the central directory */
- if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* offset of start of central directory with respect to the
- starting disk number */
- if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- us.gi.size_comment = 0;
- }
- else
- {
- central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream);
- if (central_pos==0)
- err=UNZ_ERRNO;
-
- us.isZip64 = 0;
-
- if (ZSEEK64(us.z_filefunc, us.filestream,
- central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
- err=UNZ_ERRNO;
-
- /* the signature, already checked */
- if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* number of this disk */
- if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* number of the disk with the start of the central directory */
- if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
- err=UNZ_ERRNO;
-
- /* total number of entries in the central dir on this disk */
- if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
- err=UNZ_ERRNO;
- us.gi.number_entry = uL;
-
- /* total number of entries in the central dir */
- if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
- err=UNZ_ERRNO;
- number_entry_CD = uL;
-
- if ((number_entry_CD!=us.gi.number_entry) ||
- (number_disk_with_CD!=0) ||
- (number_disk!=0))
- err=UNZ_BADZIPFILE;
-
- /* size of the central directory */
- if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
- err=UNZ_ERRNO;
- us.size_central_dir = uL;
-
- /* offset of start of central directory with respect to the
- starting disk number */
- if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
- err=UNZ_ERRNO;
- us.offset_central_dir = uL;
-
- /* zipfile comment length */
- if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
- err=UNZ_ERRNO;
- }
-
- if ((central_pospfile_in_zip_read!=NULL)
- unzCloseCurrentFile(file);
-
- ZCLOSE64(s->z_filefunc, s->filestream);
- TRYFREE(s);
- return UNZ_OK;
-}
-
-
-/*
- Write info about the ZipFile in the *pglobal_info structure.
- No preparation of the structure is needed
- return UNZ_OK if there is no problem. */
-int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info)
-{
- unz64_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- *pglobal_info=s->gi;
- return UNZ_OK;
-}
-
-int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32)
-{
- unz64_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- /* to do : check if number_entry is not truncated */
- pglobal_info32->number_entry = (uLong)s->gi.number_entry;
- pglobal_info32->size_comment = s->gi.size_comment;
- return UNZ_OK;
-}
-/*
- Translate date/time from Dos format to tm_unz (readable more easily)
-*/
-local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
-{
- ZPOS64_T uDate;
- uDate = (ZPOS64_T)(ulDosDate>>16);
- ptm->tm_mday = (uInt)(uDate&0x1f) ;
- ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
- ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
-
- ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
- ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
- ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
-}
-
-/*
- Get Info about the current file in the zipfile, with internal only info
-*/
-local int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
- unz_file_info64 *pfile_info,
- unz_file_info64_internal
- *pfile_info_internal,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize));
-
-local int unz64local_GetCurrentFileInfoInternal (unzFile file,
- unz_file_info64 *pfile_info,
- unz_file_info64_internal
- *pfile_info_internal,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize)
-{
- unz64_s* s;
- unz_file_info64 file_info;
- unz_file_info64_internal file_info_internal;
- int err=UNZ_OK;
- uLong uMagic;
- long lSeek=0;
- uLong uL;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- if (ZSEEK64(s->z_filefunc, s->filestream,
- s->pos_in_central_dir+s->byte_before_the_zipfile,
- ZLIB_FILEFUNC_SEEK_SET)!=0)
- err=UNZ_ERRNO;
-
-
- /* we check the magic */
- if (err==UNZ_OK)
- {
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
- err=UNZ_ERRNO;
- else if (uMagic!=0x02014b50)
- err=UNZ_BADZIPFILE;
- }
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
- err=UNZ_ERRNO;
-
- unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
-
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
- err=UNZ_ERRNO;
- file_info.compressed_size = uL;
-
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
- err=UNZ_ERRNO;
- file_info.uncompressed_size = uL;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
- err=UNZ_ERRNO;
-
- // relative offset of local header
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
- err=UNZ_ERRNO;
- file_info_internal.offset_curfile = uL;
-
- lSeek+=file_info.size_filename;
- if ((err==UNZ_OK) && (szFileName!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_filename0) && (fileNameBufferSize>0))
- if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
- err=UNZ_ERRNO;
- lSeek -= uSizeRead;
- }
-
- // Read extrafield
- if ((err==UNZ_OK) && (extraField!=NULL))
- {
- ZPOS64_T uSizeRead ;
- if (file_info.size_file_extraz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
- }
-
- if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
- if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead)
- err=UNZ_ERRNO;
-
- lSeek += file_info.size_file_extra - (uLong)uSizeRead;
- }
- else
- lSeek += file_info.size_file_extra;
-
-
- if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
- {
- uLong acc = 0;
-
- // since lSeek now points to after the extra field we need to move back
- lSeek -= file_info.size_file_extra;
-
- if (lSeek!=0)
- {
- if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
- }
-
- while(acc < file_info.size_file_extra)
- {
- uLong headerId;
- uLong dataSize;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK)
- err=UNZ_ERRNO;
-
- /* ZIP64 extra fields */
- if (headerId == 0x0001)
- {
- uLong uL;
-
- if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1)
- {
- if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
- err=UNZ_ERRNO;
- }
-
- if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1)
- {
- if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
- err=UNZ_ERRNO;
- }
-
- if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1)
- {
- /* Relative Header offset */
- if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
- err=UNZ_ERRNO;
- }
-
- if(file_info.disk_num_start == (unsigned long)-1)
- {
- /* Disk Start Number */
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
- err=UNZ_ERRNO;
- }
-
- }
- else
- {
- if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)
- err=UNZ_ERRNO;
- }
-
- acc += 2 + 2 + dataSize;
- }
- }
-
- if ((err==UNZ_OK) && (szComment!=NULL))
- {
- uLong uSizeRead ;
- if (file_info.size_file_commentz_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) {
- //lSeek=0;
- }
- else
- err=UNZ_ERRNO;
- }
-
- if ((file_info.size_file_comment>0) && (commentBufferSize>0))
- if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
- err=UNZ_ERRNO;
- //lSeek+=file_info.size_file_comment - uSizeRead;
- }
- //else
- // lSeek+=file_info.size_file_comment;
-
-
- if ((err==UNZ_OK) && (pfile_info!=NULL))
- *pfile_info=file_info;
-
- if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
- *pfile_info_internal=file_info_internal;
-
- return err;
-}
-
-
-
-/*
- Write info about the ZipFile in the *pglobal_info structure.
- No preparation of the structure is needed
- return UNZ_OK if there is no problem.
-*/
-int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
- unz_file_info64 * pfile_info,
- char * szFileName, uLong fileNameBufferSize,
- void *extraField, uLong extraFieldBufferSize,
- char* szComment, uLong commentBufferSize)
-{
- return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
- szFileName,fileNameBufferSize,
- extraField,extraFieldBufferSize,
- szComment,commentBufferSize);
-}
-
-int ZEXPORT unzGetCurrentFileInfo (unzFile file,
- unz_file_info * pfile_info,
- char * szFileName, uLong fileNameBufferSize,
- void *extraField, uLong extraFieldBufferSize,
- char* szComment, uLong commentBufferSize)
-{
- int err;
- unz_file_info64 file_info64;
- err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
- szFileName,fileNameBufferSize,
- extraField,extraFieldBufferSize,
- szComment,commentBufferSize);
- if (err==UNZ_OK)
- {
- pfile_info->version = file_info64.version;
- pfile_info->version_needed = file_info64.version_needed;
- pfile_info->flag = file_info64.flag;
- pfile_info->compression_method = file_info64.compression_method;
- pfile_info->dosDate = file_info64.dosDate;
- pfile_info->crc = file_info64.crc;
-
- pfile_info->size_filename = file_info64.size_filename;
- pfile_info->size_file_extra = file_info64.size_file_extra;
- pfile_info->size_file_comment = file_info64.size_file_comment;
-
- pfile_info->disk_num_start = file_info64.disk_num_start;
- pfile_info->internal_fa = file_info64.internal_fa;
- pfile_info->external_fa = file_info64.external_fa;
-
- pfile_info->tmu_date = file_info64.tmu_date,
-
-
- pfile_info->compressed_size = (uLong)file_info64.compressed_size;
- pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
-
- }
- return err;
-}
-
-/*
- Set the current file of the zipfile to the first file
- with retrieving an information about the file.
- return UNZ_OK if there is no problem
-*/
-int ZEXPORT unzGoToFirstFile64 (unzFile file,
- unz_file_info64 *pfile_info,
- char *szFileName,
- uLong fileNameBufferSize)
-{
- int err=UNZ_OK;
- unz64_s* s;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- s->pos_in_central_dir=s->offset_central_dir;
- s->num_file=0;
- err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- szFileName,fileNameBufferSize,NULL,0,NULL,0);
- s->current_file_ok = (err == UNZ_OK);
- if (pfile_info)
- *pfile_info = s->cur_file_info;
- return err;
-}
-
-/*
- Set the current file of the zipfile to the first file.
- return UNZ_OK if there is no problem
-*/
-int ZEXPORT unzGoToFirstFile (unzFile file)
-{
- return unzGoToFirstFile64(file, NULL, NULL, 0);
-}
-
-/*
- Set the current file of the zipfile to the next file
- with retrieving an information about the file.
- return UNZ_OK if there is no problem
- return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-int ZEXPORT unzGoToNextFile64 (unzFile file,
- unz_file_info64 *pfile_info,
- char *szFileName,
- uLong fileNameBufferSize)
-{
- unz64_s* s;
- int err;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- if (!s->current_file_ok)
- return UNZ_END_OF_LIST_OF_FILE;
- if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */
- if (s->num_file+1==s->gi.number_entry)
- return UNZ_END_OF_LIST_OF_FILE;
-
- s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
- s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
- s->num_file++;
- err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- szFileName,fileNameBufferSize,NULL,0,NULL,0);
- s->current_file_ok = (err == UNZ_OK);
- if (pfile_info)
- *pfile_info = s->cur_file_info;
- return err;
-}
-
-/*
- Set the current file of the zipfile to the next file.
- return UNZ_OK if there is no problem
- return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-int ZEXPORT unzGoToNextFile (unzFile file)
-{
- return unzGoToNextFile64(file, NULL, NULL, 0);
-}
-
-
-/*
- Try locate the file szFileName in the zipfile.
- For the iCaseSensitivity signification, see unzipStringFileNameCompare
-
- return value :
- UNZ_OK if the file is found. It becomes the current file.
- UNZ_END_OF_LIST_OF_FILE if the file is not found
-*/
-int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
-{
- unz64_s* s;
- int err;
-
- /* We remember the 'current' position in the file so that we can jump
- * back there if we fail.
- */
- unz_file_info64 cur_file_infoSaved;
- unz_file_info64_internal cur_file_info_internalSaved;
- ZPOS64_T num_fileSaved;
- ZPOS64_T pos_in_central_dirSaved;
-
-
- if (file==NULL)
- return UNZ_PARAMERROR;
-
- if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
- return UNZ_PARAMERROR;
-
- s=(unz64_s*)file;
- if (!s->current_file_ok)
- return UNZ_END_OF_LIST_OF_FILE;
-
- /* Save the current state */
- num_fileSaved = s->num_file;
- pos_in_central_dirSaved = s->pos_in_central_dir;
- cur_file_infoSaved = s->cur_file_info;
- cur_file_info_internalSaved = s->cur_file_info_internal;
-
- err = unzGoToFirstFile(file);
-
- while (err == UNZ_OK)
- {
- char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
- err = unzGetCurrentFileInfo64(file,NULL,
- szCurrentFileName,sizeof(szCurrentFileName)-1,
- NULL,0,NULL,0);
- if (err == UNZ_OK)
- {
- if (unzStringFileNameCompare(szCurrentFileName,
- szFileName,iCaseSensitivity)==0)
- return UNZ_OK;
- err = unzGoToNextFile(file);
- }
- }
-
- /* We failed, so restore the state of the 'current file' to where we
- * were.
- */
- s->num_file = num_fileSaved ;
- s->pos_in_central_dir = pos_in_central_dirSaved ;
- s->cur_file_info = cur_file_infoSaved;
- s->cur_file_info_internal = cur_file_info_internalSaved;
- return err;
-}
-
-
-/*
-///////////////////////////////////////////
-// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
-// I need random access
-//
-// Further optimization could be realized by adding an ability
-// to cache the directory in memory. The goal being a single
-// comprehensive file read to put the file I need in a memory.
-*/
-
-/*
-typedef struct unz_file_pos_s
-{
- ZPOS64_T pos_in_zip_directory; // offset in file
- ZPOS64_T num_of_file; // # of file
-} unz_file_pos;
-*/
-
-int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos)
-{
- unz64_s* s;
-
- if (file==NULL || file_pos==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- if (!s->current_file_ok)
- return UNZ_END_OF_LIST_OF_FILE;
-
- file_pos->pos_in_zip_directory = s->pos_in_central_dir;
- file_pos->num_of_file = s->num_file;
-
- return UNZ_OK;
-}
-
-int ZEXPORT unzGetFilePos(
- unzFile file,
- unz_file_pos* file_pos)
-{
- unz64_file_pos file_pos64;
- int err = unzGetFilePos64(file,&file_pos64);
- if (err==UNZ_OK)
- {
- file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;
- file_pos->num_of_file = (uLong)file_pos64.num_of_file;
- }
- return err;
-}
-
-int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos)
-{
- unz64_s* s;
- int err;
-
- if (file==NULL || file_pos==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
-
- /* jump to the right spot */
- s->pos_in_central_dir = file_pos->pos_in_zip_directory;
- s->num_file = file_pos->num_of_file;
-
- /* set the current file */
- err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- NULL,0,NULL,0,NULL,0);
- /* return results */
- s->current_file_ok = (err == UNZ_OK);
- return err;
-}
-
-int ZEXPORT unzGoToFilePos(
- unzFile file,
- unz_file_pos* file_pos)
-{
- unz64_file_pos file_pos64;
- if (file_pos == NULL)
- return UNZ_PARAMERROR;
-
- file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;
- file_pos64.num_of_file = file_pos->num_of_file;
- return unzGoToFilePos64(file,&file_pos64);
-}
-
-/*
-// Unzip Helper Functions - should be here?
-///////////////////////////////////////////
-*/
-
-/*
- Read the local header of the current zipfile
- Check the coherency of the local header and info in the end of central
- directory about this file
- store in *piSizeVar the size of extra info in local header
- (filename and size of extra field data)
-*/
-local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar,
- ZPOS64_T * poffset_local_extrafield,
- uInt * psize_local_extrafield)
-{
- uLong uMagic,uData,uFlags;
- uLong size_filename;
- uLong size_extra_field;
- int err=UNZ_OK;
-
- *piSizeVar = 0;
- *poffset_local_extrafield = 0;
- *psize_local_extrafield = 0;
-
- if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
- s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
- return UNZ_ERRNO;
-
-
- if (err==UNZ_OK)
- {
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
- err=UNZ_ERRNO;
- else if (uMagic!=0x04034b50)
- err=UNZ_BADZIPFILE;
- }
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
- err=UNZ_ERRNO;
-/*
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
- err=UNZ_BADZIPFILE;
-*/
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
- err=UNZ_ERRNO;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
- err=UNZ_BADZIPFILE;
-
- if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
-/* #ifdef HAVE_BZIP2 */
- (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
-/* #endif */
- (s->cur_file_info.compression_method!=Z_DEFLATED))
- err=UNZ_BADZIPFILE;
-
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
- err=UNZ_ERRNO;
-
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
-
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
- err=UNZ_ERRNO;
- else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
-
- if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
- err=UNZ_ERRNO;
- else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0))
- err=UNZ_BADZIPFILE;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
- err=UNZ_ERRNO;
- else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
- err=UNZ_BADZIPFILE;
-
- *piSizeVar += (uInt)size_filename;
-
- if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
- err=UNZ_ERRNO;
- *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
- SIZEZIPLOCALHEADER + size_filename;
- *psize_local_extrafield = (uInt)size_extra_field;
-
- *piSizeVar += (uInt)size_extra_field;
-
- return err;
-}
-
-/*
- Open for reading data the current file in the zipfile.
- If there is no error and the file is opened, the return value is UNZ_OK.
-*/
-int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
- int* level, int raw, const char* password)
-{
- int err=UNZ_OK;
- uInt iSizeVar;
- unz64_s* s;
- file_in_zip64_read_info_s* pfile_in_zip_read_info;
- ZPOS64_T offset_local_extrafield; /* offset of the local extra field */
- uInt size_local_extrafield; /* size of the local extra field */
-# ifndef NOUNCRYPT
- char source[12];
-# else
- if (password != NULL)
- return UNZ_PARAMERROR;
-# endif
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- if (!s->current_file_ok)
- return UNZ_PARAMERROR;
-
- if (s->pfile_in_zip_read != NULL)
- unzCloseCurrentFile(file);
-
- if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
- return UNZ_BADZIPFILE;
-
- pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s));
- if (pfile_in_zip_read_info==NULL)
- return UNZ_INTERNALERROR;
-
- pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
- pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
- pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
- pfile_in_zip_read_info->pos_local_extrafield=0;
- pfile_in_zip_read_info->raw=raw;
-
- if (pfile_in_zip_read_info->read_buffer==NULL)
- {
- TRYFREE(pfile_in_zip_read_info);
- return UNZ_INTERNALERROR;
- }
-
- pfile_in_zip_read_info->stream_initialised=0;
-
- if (method!=NULL)
- *method = (int)s->cur_file_info.compression_method;
-
- if (level!=NULL)
- {
- *level = 6;
- switch (s->cur_file_info.flag & 0x06)
- {
- case 6 : *level = 1; break;
- case 4 : *level = 2; break;
- case 2 : *level = 9; break;
- }
- }
-
- if ((s->cur_file_info.compression_method!=0) &&
-/* #ifdef HAVE_BZIP2 */
- (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
-/* #endif */
- (s->cur_file_info.compression_method!=Z_DEFLATED)) {
-
- //err=UNZ_BADZIPFILE;
- }
- pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
- pfile_in_zip_read_info->crc32=0;
- pfile_in_zip_read_info->total_out_64=0;
- pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method;
- pfile_in_zip_read_info->filestream=s->filestream;
- pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
- pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
-
- pfile_in_zip_read_info->stream.total_out = 0;
-
- if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw))
- {
-#ifdef HAVE_BZIP2
- pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
- pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
- pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
- pfile_in_zip_read_info->bstream.state = (voidpf)0;
-
- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
- pfile_in_zip_read_info->stream.zfree = (free_func)0;
- pfile_in_zip_read_info->stream.opaque = (voidpf)0;
- pfile_in_zip_read_info->stream.next_in = (voidpf)0;
- pfile_in_zip_read_info->stream.avail_in = 0;
-
- err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
- if (err == Z_OK)
- pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
- else
- {
- TRYFREE(pfile_in_zip_read_info);
- return err;
- }
-#else
- pfile_in_zip_read_info->raw=1;
-#endif
- }
- else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
- {
- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
- pfile_in_zip_read_info->stream.zfree = (free_func)0;
- pfile_in_zip_read_info->stream.opaque = (voidpf)0;
- pfile_in_zip_read_info->stream.next_in = 0;
- pfile_in_zip_read_info->stream.avail_in = 0;
-
- err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
- if (err == Z_OK)
- pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
- else
- {
- TRYFREE(pfile_in_zip_read_info);
- return err;
- }
- /* windowBits is passed < 0 to tell that there is no zlib header.
- * Note that in this case inflate *requires* an extra "dummy" byte
- * after the compressed stream in order to complete decompression and
- * return Z_STREAM_END.
- * In unzip, i don't wait absolutely Z_STREAM_END because I known the
- * size of both compressed and uncompressed data
- */
- }
- pfile_in_zip_read_info->rest_read_compressed =
- s->cur_file_info.compressed_size ;
- pfile_in_zip_read_info->rest_read_uncompressed =
- s->cur_file_info.uncompressed_size ;
-
-
- pfile_in_zip_read_info->pos_in_zipfile =
- s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
- iSizeVar;
-
- pfile_in_zip_read_info->stream.avail_in = (uInt)0;
-
- s->pfile_in_zip_read = pfile_in_zip_read_info;
- s->encrypted = 0;
-
-# ifndef NOUNCRYPT
- if (password != NULL)
- {
- int i;
- s->pcrc_32_tab = get_crc_table();
- init_keys(password,s->keys,s->pcrc_32_tab);
- if (ZSEEK64(s->z_filefunc, s->filestream,
- s->pfile_in_zip_read->pos_in_zipfile +
- s->pfile_in_zip_read->byte_before_the_zipfile,
- SEEK_SET)!=0)
- return UNZ_INTERNALERROR;
- if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12)
- return UNZ_INTERNALERROR;
-
- for (i = 0; i<12; i++)
- zdecode(s->keys,s->pcrc_32_tab,source[i]);
-
- s->pfile_in_zip_read->pos_in_zipfile+=12;
- s->encrypted=1;
- }
-# endif
-
-
- return UNZ_OK;
-}
-
-int ZEXPORT unzOpenCurrentFile (unzFile file)
-{
- return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
-}
-
-int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password)
-{
- return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
-}
-
-int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw)
-{
- return unzOpenCurrentFile3(file, method, level, raw, NULL);
-}
-
-/** Addition for GDAL : START */
-
-ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
-{
- unz64_s* s;
- file_in_zip64_read_info_s* pfile_in_zip_read_info;
- s=(unz64_s*)file;
- if (file==NULL)
- return 0; //UNZ_PARAMERROR;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
- if (pfile_in_zip_read_info==NULL)
- return 0; //UNZ_PARAMERROR;
- return pfile_in_zip_read_info->pos_in_zipfile +
- pfile_in_zip_read_info->byte_before_the_zipfile;
-}
-
-/** Addition for GDAL : END */
-
-/*
- Read bytes from the current file.
- buf contain buffer where data must be copied
- len the size of buf.
-
- return the number of byte copied if some bytes are copied
- return 0 if the end of file was reached
- return <0 with error code if there is an error
- (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-*/
-int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
-{
- int err=UNZ_OK;
- uInt iRead = 0;
- unz64_s* s;
- file_in_zip64_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
-
- if (pfile_in_zip_read_info->read_buffer == NULL)
- return UNZ_END_OF_LIST_OF_FILE;
- if (len==0)
- return 0;
-
- pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
-
- pfile_in_zip_read_info->stream.avail_out = (uInt)len;
-
- if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
- (!(pfile_in_zip_read_info->raw)))
- pfile_in_zip_read_info->stream.avail_out =
- (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
-
- if ((len>pfile_in_zip_read_info->rest_read_compressed+
- pfile_in_zip_read_info->stream.avail_in) &&
- (pfile_in_zip_read_info->raw))
- pfile_in_zip_read_info->stream.avail_out =
- (uInt)pfile_in_zip_read_info->rest_read_compressed+
- pfile_in_zip_read_info->stream.avail_in;
-
- while (pfile_in_zip_read_info->stream.avail_out>0)
- {
- if ((pfile_in_zip_read_info->stream.avail_in==0) &&
- (pfile_in_zip_read_info->rest_read_compressed>0))
- {
- uInt uReadThis = UNZ_BUFSIZE;
- if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed;
- if (uReadThis == 0)
- return UNZ_EOF;
- if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->filestream,
- pfile_in_zip_read_info->pos_in_zipfile +
- pfile_in_zip_read_info->byte_before_the_zipfile,
- ZLIB_FILEFUNC_SEEK_SET)!=0)
- return UNZ_ERRNO;
- if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->filestream,
- pfile_in_zip_read_info->read_buffer,
- uReadThis)!=uReadThis)
- return UNZ_ERRNO;
-
-
-# ifndef NOUNCRYPT
- if(s->encrypted)
- {
- uInt i;
- for(i=0;iread_buffer[i] =
- zdecode(s->keys,s->pcrc_32_tab,
- pfile_in_zip_read_info->read_buffer[i]);
- }
-# endif
-
-
- pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
-
- pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
-
- pfile_in_zip_read_info->stream.next_in =
- (Bytef*)pfile_in_zip_read_info->read_buffer;
- pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
- }
-
- if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
- {
- uInt uDoCopy,i ;
-
- if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
- (pfile_in_zip_read_info->rest_read_compressed == 0))
- return (iRead==0) ? UNZ_EOF : iRead;
-
- if (pfile_in_zip_read_info->stream.avail_out <
- pfile_in_zip_read_info->stream.avail_in)
- uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
- else
- uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
-
- for (i=0;istream.next_out+i) =
- *(pfile_in_zip_read_info->stream.next_in+i);
-
- pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy;
-
- pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
- pfile_in_zip_read_info->stream.next_out,
- uDoCopy);
- pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
- pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
- pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
- pfile_in_zip_read_info->stream.next_out += uDoCopy;
- pfile_in_zip_read_info->stream.next_in += uDoCopy;
- pfile_in_zip_read_info->stream.total_out += uDoCopy;
- iRead += uDoCopy;
- }
- else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
- {
-#ifdef HAVE_BZIP2
- uLong uTotalOutBefore,uTotalOutAfter;
- const Bytef *bufBefore;
- uLong uOutThis;
-
- pfile_in_zip_read_info->bstream.next_in = (char*)pfile_in_zip_read_info->stream.next_in;
- pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in;
- pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in;
- pfile_in_zip_read_info->bstream.total_in_hi32 = 0;
- pfile_in_zip_read_info->bstream.next_out = (char*)pfile_in_zip_read_info->stream.next_out;
- pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out;
- pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
- pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
-
- uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
- bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out;
-
- err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
-
- uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
- uOutThis = uTotalOutAfter-uTotalOutBefore;
-
- pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
-
- pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis));
- pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;
- iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
- pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->bstream.next_in;
- pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in;
- pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32;
- pfile_in_zip_read_info->stream.next_out = (Bytef*)pfile_in_zip_read_info->bstream.next_out;
- pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
- pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
-
- if (err==BZ_STREAM_END)
- return (iRead==0) ? UNZ_EOF : iRead;
- if (err!=BZ_OK)
- break;
-#endif
- } // end Z_BZIP2ED
- else
- {
- ZPOS64_T uTotalOutBefore,uTotalOutAfter;
- const Bytef *bufBefore;
- ZPOS64_T uOutThis;
- int flush=Z_SYNC_FLUSH;
-
- uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
- bufBefore = pfile_in_zip_read_info->stream.next_out;
-
- /*
- if ((pfile_in_zip_read_info->rest_read_uncompressed ==
- pfile_in_zip_read_info->stream.avail_out) &&
- (pfile_in_zip_read_info->rest_read_compressed == 0))
- flush = Z_FINISH;
- */
- err=inflate(&pfile_in_zip_read_info->stream,flush);
-
- if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
- err = Z_DATA_ERROR;
-
- uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
- uOutThis = uTotalOutAfter-uTotalOutBefore;
-
- pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
-
- pfile_in_zip_read_info->crc32 =
- crc32(pfile_in_zip_read_info->crc32,bufBefore,
- (uInt)(uOutThis));
-
- pfile_in_zip_read_info->rest_read_uncompressed -=
- uOutThis;
-
- iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
-
- if (err==Z_STREAM_END)
- return (iRead==0) ? UNZ_EOF : iRead;
- if (err!=Z_OK)
- break;
- }
- }
-
- if (err==Z_OK)
- return iRead;
- return err;
-}
-
-
-/*
- Give the current position in uncompressed data
-*/
-z_off_t ZEXPORT unztell (unzFile file)
-{
- unz64_s* s;
- file_in_zip64_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- return (z_off_t)pfile_in_zip_read_info->stream.total_out;
-}
-
-ZPOS64_T ZEXPORT unztell64 (unzFile file)
-{
-
- unz64_s* s;
- file_in_zip64_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return (ZPOS64_T)-1;
- s=(unz64_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return (ZPOS64_T)-1;
-
- return pfile_in_zip_read_info->total_out_64;
-}
-
-
-/*
- return 1 if the end of file was reached, 0 elsewhere
-*/
-int ZEXPORT unzeof (unzFile file)
-{
- unz64_s* s;
- file_in_zip64_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
- return 1;
- else
- return 0;
-}
-
-
-
-/*
-Read extra field from the current file (opened by unzOpenCurrentFile)
-This is the local-header version of the extra field (sometimes, there is
-more info in the local-header version than in the central-header)
-
- if buf==NULL, it return the size of the local extra field that can be read
-
- if buf!=NULL, len is the size of the buffer, the extra header is copied in
- buf.
- the return value is the number of bytes copied in buf, or (if <0)
- the error code
-*/
-int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
-{
- unz64_s* s;
- file_in_zip64_read_info_s* pfile_in_zip_read_info;
- uInt read_now;
- ZPOS64_T size_to_read;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
- pfile_in_zip_read_info->pos_local_extrafield);
-
- if (buf==NULL)
- return (int)size_to_read;
-
- if (len>size_to_read)
- read_now = (uInt)size_to_read;
- else
- read_now = (uInt)len ;
-
- if (read_now==0)
- return 0;
-
- if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->filestream,
- pfile_in_zip_read_info->offset_local_extrafield +
- pfile_in_zip_read_info->pos_local_extrafield,
- ZLIB_FILEFUNC_SEEK_SET)!=0)
- return UNZ_ERRNO;
-
- if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->filestream,
- buf,read_now)!=read_now)
- return UNZ_ERRNO;
-
- return (int)read_now;
-}
-
-/*
- Close the file in zip opened with unzipOpenCurrentFile
- Return UNZ_CRCERROR if all the file was read but the CRC is not good
-*/
-int ZEXPORT unzCloseCurrentFile (unzFile file)
-{
- int err=UNZ_OK;
-
- unz64_s* s;
- file_in_zip64_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
-
- if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
- (!pfile_in_zip_read_info->raw))
- {
- if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
- err=UNZ_CRCERROR;
- }
-
-
- TRYFREE(pfile_in_zip_read_info->read_buffer);
- pfile_in_zip_read_info->read_buffer = NULL;
- if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
- inflateEnd(&pfile_in_zip_read_info->stream);
-#ifdef HAVE_BZIP2
- else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
- BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
-#endif
-
-
- pfile_in_zip_read_info->stream_initialised = 0;
- TRYFREE(pfile_in_zip_read_info);
-
- s->pfile_in_zip_read=NULL;
-
- return err;
-}
-
-
-/*
- Get the global comment string of the ZipFile, in the szComment buffer.
- uSizeBuf is the size of the szComment buffer.
- return the number of byte copied or an error code <0
-*/
-int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf)
-{
- unz64_s* s;
- uLong uReadThis ;
- if (file==NULL)
- return (int)UNZ_PARAMERROR;
- s=(unz64_s*)file;
-
- uReadThis = uSizeBuf;
- if (uReadThis>s->gi.size_comment)
- uReadThis = s->gi.size_comment;
-
- if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
- return UNZ_ERRNO;
-
- if (uReadThis>0)
- {
- *szComment='\0';
- if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
- return UNZ_ERRNO;
- }
-
- if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
- *(szComment+s->gi.size_comment)='\0';
- return (int)uReadThis;
-}
-
-/* Additions by RX '2004 */
-ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
-{
- unz64_s* s;
-
- if (file==NULL)
- return 0; //UNZ_PARAMERROR;
- s=(unz64_s*)file;
- if (!s->current_file_ok)
- return 0;
- if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
- if (s->num_file==s->gi.number_entry)
- return 0;
- return s->pos_in_central_dir;
-}
-
-uLong ZEXPORT unzGetOffset (unzFile file)
-{
- ZPOS64_T offset64;
-
- if (file==NULL)
- return 0; //UNZ_PARAMERROR;
- offset64 = unzGetOffset64(file);
- return (uLong)offset64;
-}
-
-int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
-{
- unz64_s* s;
- int err;
-
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
-
- s->pos_in_central_dir = pos;
- s->num_file = s->gi.number_entry; /* hack */
- err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
- &s->cur_file_info_internal,
- NULL,0,NULL,0,NULL,0);
- s->current_file_ok = (err == UNZ_OK);
- return err;
-}
-
-int ZEXPORT unzSetOffset (unzFile file, uLong pos)
-{
- return unzSetOffset64(file,pos);
-}
-
-} // end of namespace cocos2d
diff --git a/cocos/2d/support/zip_support/unzip.h b/cocos/2d/support/zip_support/unzip.h
deleted file mode 100644
index 54e73a55ea..0000000000
--- a/cocos/2d/support/zip_support/unzip.h
+++ /dev/null
@@ -1,455 +0,0 @@
-/* unzip.h -- IO for uncompress .zip files using zlib
- Version 1.1, February 14h, 2010
- part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
-
- Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
-
- Modifications of Unzip for Zip64
- Copyright (C) 2007-2008 Even Rouault
-
- Modifications for Zip64 support on both zip and unzip
- Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
-
- For more info read MiniZip_info.txt
-
- ---------------------------------------------------------------------------------
-
- Condition of use and distribution are the same than zlib :
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- ---------------------------------------------------------------------------------
-
- Changes
-
- See header of unzip64.c
-
-*/
-
-#ifndef _unz64_H
-#define _unz64_H
-
-#include "CCPlatformDefine.h"
-
-#ifndef _ZLIB_H
-#include "zlib.h"
-#endif
-
-#ifndef _ZLIBIOAPI_H
-#include "ioapi.h"
-#endif
-
-#ifdef HAVE_BZIP2
-#include "bzlib.h"
-#endif
-
-#define Z_BZIP2ED 12
-
-#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
-/* like the STRICT of WIN32, we define a pointer that cannot be converted
- from (void*) without cast */
-typedef struct TagunzFile__ { int unused; } unzFile__;
-typedef unzFile__ *unzFile;
-#else
-typedef voidp unzFile;
-#endif
-
-
-#define UNZ_OK (0)
-#define UNZ_END_OF_LIST_OF_FILE (-100)
-#define UNZ_ERRNO (Z_ERRNO)
-#define UNZ_EOF (0)
-#define UNZ_PARAMERROR (-102)
-#define UNZ_BADZIPFILE (-103)
-#define UNZ_INTERNALERROR (-104)
-#define UNZ_CRCERROR (-105)
-
-namespace cocos2d {
-
-/* tm_unz contain date/time info */
-typedef struct tm_unz_s
-{
- uInt tm_sec; /* seconds after the minute - [0,59] */
- uInt tm_min; /* minutes after the hour - [0,59] */
- uInt tm_hour; /* hours since midnight - [0,23] */
- uInt tm_mday; /* day of the month - [1,31] */
- uInt tm_mon; /* months since January - [0,11] */
- uInt tm_year; /* years - [1980..2044] */
-} tm_unz;
-
-/* unz_global_info structure contain global data about the ZIPfile
- These data comes from the end of central dir */
-typedef struct unz_global_info64_s
-{
- ZPOS64_T number_entry; /* total number of entries in
- the central dir on this disk */
- uLong size_comment; /* size of the global comment of the zipfile */
-} unz_global_info64;
-
-typedef struct unz_global_info_s
-{
- uLong number_entry; /* total number of entries in
- the central dir on this disk */
- uLong size_comment; /* size of the global comment of the zipfile */
-} unz_global_info;
-
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_info64_s
-{
- uLong version; /* version made by 2 bytes */
- uLong version_needed; /* version needed to extract 2 bytes */
- uLong flag; /* general purpose bit flag 2 bytes */
- uLong compression_method; /* compression method 2 bytes */
- uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
- uLong crc; /* crc-32 4 bytes */
- ZPOS64_T compressed_size; /* compressed size 8 bytes */
- ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
- uLong size_filename; /* filename length 2 bytes */
- uLong size_file_extra; /* extra field length 2 bytes */
- uLong size_file_comment; /* file comment length 2 bytes */
-
- uLong disk_num_start; /* disk number start 2 bytes */
- uLong internal_fa; /* internal file attributes 2 bytes */
- uLong external_fa; /* external file attributes 4 bytes */
-
- tm_unz tmu_date;
-} unz_file_info64;
-
-typedef struct unz_file_info_s
-{
- uLong version; /* version made by 2 bytes */
- uLong version_needed; /* version needed to extract 2 bytes */
- uLong flag; /* general purpose bit flag 2 bytes */
- uLong compression_method; /* compression method 2 bytes */
- uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
- uLong crc; /* crc-32 4 bytes */
- uLong compressed_size; /* compressed size 4 bytes */
- uLong uncompressed_size; /* uncompressed size 4 bytes */
- uLong size_filename; /* filename length 2 bytes */
- uLong size_file_extra; /* extra field length 2 bytes */
- uLong size_file_comment; /* file comment length 2 bytes */
-
- uLong disk_num_start; /* disk number start 2 bytes */
- uLong internal_fa; /* internal file attributes 2 bytes */
- uLong external_fa; /* external file attributes 4 bytes */
-
- tm_unz tmu_date;
-} unz_file_info;
-
-int CC_DLL unzStringFileNameCompare OF ((const char* fileName1,
- const char* fileName2,
- int iCaseSensitivity));
-/*
- Compare two filename (fileName1,fileName2).
- If iCaseSenisivity = 1, comparison is case sensitivity (like strcmp)
- If iCaseSenisivity = 2, comparison is not case sensitivity (like strcmpi
- or strcasecmp)
- If iCaseSenisivity = 0, case sensitivity is default of your operating system
- (like 1 on Unix, 2 on Windows)
-*/
-
-
-unzFile CC_DLL unzOpen OF((const char *path));
-unzFile CC_DLL unzOpen64 OF((const void *path));
-/*
- Open a Zip file. path contain the full pathname (by example,
- on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
- "zlib/zlib113.zip".
- If the zipfile cannot be opened (file don't exist or in not valid), the
- return value is NULL.
- Else, the return value is a unzFile Handle, usable with other function
- of this unzip package.
- the "64" function take a const void* pointer, because the path is just the
- value passed to the open64_file_func callback.
- Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
- is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
- does not describe the reality
-*/
-
-
-unzFile CC_DLL unzOpen2 OF((const char *path,
- zlib_filefunc_def* pzlib_filefunc_def));
-/*
- Open a Zip file, like unzOpen, but provide a set of file low level API
- for read/write the zip file (see ioapi.h)
-*/
-
-unzFile CC_DLL unzOpen2_64 OF((const void *path,
- zlib_filefunc64_def* pzlib_filefunc_def));
-/*
- Open a Zip file, like unz64Open, but provide a set of file low level API
- for read/write the zip file (see ioapi.h)
-*/
-
-int CC_DLL unzClose OF((unzFile file));
-/*
- Close a ZipFile opened with unzipOpen.
- If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
- these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
- return UNZ_OK if there is no problem. */
-
-int CC_DLL unzGetGlobalInfo OF((unzFile file,
- unz_global_info *pglobal_info));
-
-int CC_DLL unzGetGlobalInfo64 OF((unzFile file,
- unz_global_info64 *pglobal_info));
-/*
- Write info about the ZipFile in the *pglobal_info structure.
- No preparation of the structure is needed
- return UNZ_OK if there is no problem. */
-
-
-int CC_DLL unzGetGlobalComment OF((unzFile file,
- char *szComment,
- uLong uSizeBuf));
-/*
- Get the global comment string of the ZipFile, in the szComment buffer.
- uSizeBuf is the size of the szComment buffer.
- return the number of byte copied or an error code <0
-*/
-
-
-/***************************************************************************/
-/* Unzip package allow you browse the directory of the zipfile */
-
-int CC_DLL unzGoToFirstFile OF((unzFile file));
-
-/*
- Set the current file of the zipfile to the first file.
- return UNZ_OK if there is no problem
-*/
-
-int CC_DLL unzGoToFirstFile64 OF((unzFile file,
- unz_file_info64 *pfile_info,
- char *szFileName,
- uLong fileNameBufferSize));
-/*
- Set the current file of the zipfile to the first file
- with retrieving an information about the file.
- return UNZ_OK if there is no problem
-*/
-
-int CC_DLL unzGoToNextFile OF((unzFile file));
-/*
- Set the current file of the zipfile to the next file.
- return UNZ_OK if there is no problem
- return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-
-int CC_DLL unzGoToNextFile64 OF((unzFile file,
- unz_file_info64 *pfile_info,
- char *szFileName,
- uLong fileNameBufferSize));
-/*
- Set the current file of the zipfile to the next file
- with retrieving an information about the file.
- return UNZ_OK if there is no problem
- return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
-*/
-
-int CC_DLL unzLocateFile OF((unzFile file,
- const char *szFileName,
- int iCaseSensitivity));
-/*
- Try locate the file szFileName in the zipfile.
- For the iCaseSensitivity signification, see unzStringFileNameCompare
-
- return value :
- UNZ_OK if the file is found. It becomes the current file.
- UNZ_END_OF_LIST_OF_FILE if the file is not found
-*/
-
-
-/* ****************************************** */
-/* Ryan supplied functions */
-/* unz_file_info contain information about a file in the zipfile */
-typedef struct unz_file_pos_s
-{
- uLong pos_in_zip_directory; /* offset in zip file directory */
- uLong num_of_file; /* # of file */
-} unz_file_pos;
-
-int CC_DLL unzGetFilePos(
- unzFile file,
- unz_file_pos* file_pos);
-
-int CC_DLL unzGoToFilePos(
- unzFile file,
- unz_file_pos* file_pos);
-
-typedef struct unz64_file_pos_s
-{
- ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
- ZPOS64_T num_of_file; /* # of file */
-} unz64_file_pos;
-
-int CC_DLL unzGetFilePos64(
- unzFile file,
- unz64_file_pos* file_pos);
-
-int CC_DLL unzGoToFilePos64(
- unzFile file,
- const unz64_file_pos* file_pos);
-
-/* ****************************************** */
-
-int CC_DLL unzGetCurrentFileInfo64 OF((unzFile file,
- unz_file_info64 *pfile_info,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize));
-
-int CC_DLL unzGetCurrentFileInfo OF((unzFile file,
- unz_file_info *pfile_info,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize));
-/*
- Get Info about the current file
- if pfile_info!=NULL, the *pfile_info structure will contain some info about
- the current file
- if szFileName!=NULL, the filename string will be copied in szFileName
- (fileNameBufferSize is the size of the buffer)
- if extraField!=NULL, the extra field information will be copied in extraField
- (extraFieldBufferSize is the size of the buffer).
- This is the Central-header version of the extra field
- if szComment!=NULL, the comment string of the file will be copied in szComment
- (commentBufferSize is the size of the buffer)
-*/
-
-
-/** Addition for GDAL : START */
-
-ZPOS64_T CC_DLL unzGetCurrentFileZStreamPos64 OF((unzFile file));
-
-/** Addition for GDAL : END */
-
-
-/***************************************************************************/
-/* for reading the content of the current zipfile, you can open it, read data
- from it, and close it (you can close it before reading all the file)
- */
-
-int CC_DLL unzOpenCurrentFile OF((unzFile file));
-/*
- Open for reading data the current file in the zipfile.
- If there is no error, the return value is UNZ_OK.
-*/
-
-int CC_DLL unzOpenCurrentFilePassword OF((unzFile file,
- const char* password));
-/*
- Open for reading data the current file in the zipfile.
- password is a crypting password
- If there is no error, the return value is UNZ_OK.
-*/
-
-int CC_DLL unzOpenCurrentFile2 OF((unzFile file,
- int* method,
- int* level,
- int raw));
-/*
- Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
- if raw==1
- *method will receive method of compression, *level will receive level of
- compression
- note : you can set level parameter as NULL (if you did not want known level,
- but you CANNOT set method parameter as NULL
-*/
-
-int CC_DLL unzOpenCurrentFile3 OF((unzFile file,
- int* method,
- int* level,
- int raw,
- const char* password));
-/*
- Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
- if raw==1
- *method will receive method of compression, *level will receive level of
- compression
- note : you can set level parameter as NULL (if you did not want known level,
- but you CANNOT set method parameter as NULL
-*/
-
-
-int CC_DLL unzCloseCurrentFile OF((unzFile file));
-/*
- Close the file in zip opened with unzOpenCurrentFile
- Return UNZ_CRCERROR if all the file was read but the CRC is not good
-*/
-
-int CC_DLL unzReadCurrentFile OF((unzFile file,
- voidp buf,
- unsigned len));
-/*
- Read bytes from the current file (opened by unzOpenCurrentFile)
- buf contain buffer where data must be copied
- len the size of buf.
-
- return the number of byte copied if some bytes are copied
- return 0 if the end of file was reached
- return <0 with error code if there is an error
- (UNZ_ERRNO for IO error, or zLib error for uncompress error)
-*/
-
-z_off_t CC_DLL unztell OF((unzFile file));
-
-ZPOS64_T CC_DLL unztell64 OF((unzFile file));
-/*
- Give the current position in uncompressed data
-*/
-
-int CC_DLL unzeof OF((unzFile file));
-/*
- return 1 if the end of file was reached, 0 elsewhere
-*/
-
-int CC_DLL unzGetLocalExtrafield OF((unzFile file,
- voidp buf,
- unsigned len));
-/*
- Read extra field from the current file (opened by unzOpenCurrentFile)
- This is the local-header version of the extra field (sometimes, there is
- more info in the local-header version than in the central-header)
-
- if buf==NULL, it return the size of the local extra field
-
- if buf!=NULL, len is the size of the buffer, the extra header is copied in
- buf.
- the return value is the number of bytes copied in buf, or (if <0)
- the error code
-*/
-
-/***************************************************************************/
-
-/* Get the current file offset */
-ZPOS64_T CC_DLL unzGetOffset64 (unzFile file);
-uLong CC_DLL unzGetOffset (unzFile file);
-
-/* Set the current file offset */
-int CC_DLL unzSetOffset64 (unzFile file, ZPOS64_T pos);
-int CC_DLL unzSetOffset (unzFile file, uLong pos);
-
-} // end of namespace cocos2d
-
-#endif /* _unz64_H */
diff --git a/cocos/2d/support/data_support/uthash.h b/cocos/2d/uthash.h
similarity index 100%
rename from cocos/2d/support/data_support/uthash.h
rename to cocos/2d/uthash.h
diff --git a/cocos/2d/support/data_support/utlist.h b/cocos/2d/utlist.h
similarity index 100%
rename from cocos/2d/support/data_support/utlist.h
rename to cocos/2d/utlist.h
diff --git a/cocos/platform/CCPlatformConfig.h b/cocos/platform/CCPlatformConfig.h
deleted file mode 100644
index 5ba0757dac..0000000000
--- a/cocos/platform/CCPlatformConfig.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-Copyright (c) 2010 cocos2d-x.org
-
-http://www.cocos2d-x.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-****************************************************************************/
-
-#ifndef __CC_PLATFORM_CONFIG_H__
-#define __CC_PLATFORM_CONFIG_H__
-
-/**
-Config of cocos2d-x project, per target platform.
-*/
-
-//////////////////////////////////////////////////////////////////////////
-// pre configure
-//////////////////////////////////////////////////////////////////////////
-
-// define supported target platform macro which CC uses.
-#define CC_PLATFORM_UNKNOWN 0
-#define CC_PLATFORM_IOS 1
-#define CC_PLATFORM_ANDROID 2
-#define CC_PLATFORM_WIN32 3
-#define CC_PLATFORM_MARMALADE 4
-#define CC_PLATFORM_LINUX 5
-#define CC_PLATFORM_BADA 6
-#define CC_PLATFORM_BLACKBERRY 7
-#define CC_PLATFORM_MAC 8
-#define CC_PLATFORM_NACL 9
-#define CC_PLATFORM_EMSCRIPTEN 10
-#define CC_PLATFORM_TIZEN 11
-#define CC_PLATFORM_QT5 12
-
-// Determine target platform by compile environment macro.
-#define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
-
-// mac
-#if defined(CC_TARGET_OS_MAC)
-#undef CC_TARGET_PLATFORM
-#define CC_TARGET_PLATFORM CC_PLATFORM_MAC
-#endif
-
-// iphone
-#if defined(CC_TARGET_OS_IPHONE)
- #undef CC_TARGET_PLATFORM
- #define CC_TARGET_PLATFORM CC_PLATFORM_IOS
-#endif
-
-// android
-#if defined(ANDROID)
- #undef CC_TARGET_PLATFORM
- #define CC_TARGET_PLATFORM CC_PLATFORM_ANDROID
-#endif
-
-// win32
-#if defined(WIN32) && defined(_WINDOWS)
- #undef CC_TARGET_PLATFORM
- #define CC_TARGET_PLATFORM CC_PLATFORM_WIN32
-#endif
-
-// linux
-#if defined(LINUX)
- #undef CC_TARGET_PLATFORM
- #define CC_TARGET_PLATFORM CC_PLATFORM_LINUX
-#endif
-
-// marmalade
-#if defined(MARMALADE)
-#undef CC_TARGET_PLATFORM
-#define CC_TARGET_PLATFORM CC_PLATFORM_MARMALADE
-#endif
-
-// bada
-#if defined(SHP)
-#undef CC_TARGET_PLATFORM
-#define CC_TARGET_PLATFORM CC_PLATFORM_BADA
-#endif
-
-// qnx
-#if defined(__QNX__)
- #undef CC_TARGET_PLATFORM
- #define CC_TARGET_PLATFORM CC_PLATFORM_BLACKBERRY
-#endif
-
-// native client
-#if defined(__native_client__)
- #undef CC_TARGET_PLATFORM
- #define CC_TARGET_PLATFORM CC_PLATFORM_NACL
-#endif
-
-// Emscripten
-#if defined(EMSCRIPTEN)
- #undef CC_TARGET_PLATFORM
- #define CC_TARGET_PLATFORM CC_PLATFORM_EMSCRIPTEN
-#endif
-
-// tizen
-#if defined(TIZEN)
- #undef CC_TARGET_PLATFORM
- #define CC_TARGET_PLATFORM CC_PLATFORM_TIZEN
-#endif
-
-// qt5
-#if defined(CC_TARGET_QT5)
- #undef CC_TARGET_PLATFORM
- #define CC_TARGET_PLATFORM CC_PLATFORM_QT5
-#endif
-
-//////////////////////////////////////////////////////////////////////////
-// post configure
-//////////////////////////////////////////////////////////////////////////
-
-// check user set platform
-#if ! CC_TARGET_PLATFORM
- #error "Cannot recognize the target platform; are you targeting an unsupported platform?"
-#endif
-
-#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
-#pragma warning (disable:4127)
-#endif // CC_PLATFORM_WIN32
-
-#endif // __CC_PLATFORM_CONFIG_H__
-
diff --git a/cocos/platform/CCPlatformMacros.h b/cocos/platform/CCPlatformMacros.h
deleted file mode 100644
index fca1255c0d..0000000000
--- a/cocos/platform/CCPlatformMacros.h
+++ /dev/null
@@ -1,301 +0,0 @@
-/****************************************************************************
- Copyright (c) 2010 cocos2d-x.org
-
- http://www.cocos2d-x.org
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
-#ifndef __CC_PLATFORM_MACROS_H__
-#define __CC_PLATFORM_MACROS_H__
-
-/**
- * define some platform specific macros
- */
-#include "ccConfig.h"
-#include "CCPlatformConfig.h"
-#include "CCPlatformDefine.h"
-
-/**
- * define a create function for a specific type, such as Layer
- * @param \__TYPE__ class type to add create(), such as Layer
- */
-#define CREATE_FUNC(__TYPE__) \
-static __TYPE__* create() \
-{ \
- __TYPE__ *pRet = new __TYPE__(); \
- if (pRet && pRet->init()) \
- { \
- pRet->autorelease(); \
- return pRet; \
- } \
- else \
- { \
- delete pRet; \
- pRet = NULL; \
- return NULL; \
- } \
-}
-
-/**
- * define a node function for a specific type, such as Layer
- * @param \__TYPE__ class type to add node(), such as Layer
- * @deprecated This interface will be deprecated sooner or later.
- */
-#define NODE_FUNC(__TYPE__) \
-CC_DEPRECATED_ATTRIBUTE static __TYPE__* node() \
-{ \
- __TYPE__ *pRet = new __TYPE__(); \
- if (pRet && pRet->init()) \
- { \
- pRet->autorelease(); \
- return pRet; \
- } \
- else \
- { \
- delete pRet; \
- pRet = NULL; \
- return NULL; \
- } \
-}
-
-/** @def CC_ENABLE_CACHE_TEXTURE_DATA
-Enable it if you want to cache the texture data.
-Not enabling for Emscripten any more -- doesn't seem necessary and don't want
-to be different from other platforms unless there's a good reason.
-
-It's new in cocos2d-x since v0.99.5
-*/
-#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
- #define CC_ENABLE_CACHE_TEXTURE_DATA 1
-#else
- #define CC_ENABLE_CACHE_TEXTURE_DATA 0
-#endif
-
-#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_EMSCRIPTEN)
- /* Application will crash in glDrawElements function on some win32 computers and some android devices.
- Indices should be bound again while drawing to avoid this bug.
- */
- #define CC_REBIND_INDICES_BUFFER 1
-#else
- #define CC_REBIND_INDICES_BUFFER 0
-#endif
-
-// generic macros
-
-// namespace cocos2d {}
-#ifdef __cplusplus
- #define NS_CC_BEGIN namespace cocos2d {
- #define NS_CC_END }
- #define USING_NS_CC using namespace cocos2d
-#else
- #define NS_CC_BEGIN
- #define NS_CC_END
- #define USING_NS_CC
-#endif
-
-/** CC_PROPERTY_READONLY is used to declare a protected variable.
- We can use getter to read the variable.
- @param varType the type of variable.
- @param varName variable name.
- @param funName "get + funName" will be the name of the getter.
- @warning The getter is a public virtual function, you should rewrite it first.
- The variables and methods declared after CC_PROPERTY_READONLY are all public.
- If you need protected or private, please declare.
- */
-#define CC_PROPERTY_READONLY(varType, varName, funName)\
-protected: varType varName;\
-public: virtual varType get##funName(void) const;
-
-#define CC_PROPERTY_READONLY_PASS_BY_REF(varType, varName, funName)\
-protected: varType varName;\
-public: virtual const varType& get##funName(void) const;
-
-/** CC_PROPERTY is used to declare a protected variable.
- We can use getter to read the variable, and use the setter to change the variable.
- @param varType the type of variable.
- @param varName variable name.
- @param funName "get + funName" will be the name of the getter.
- "set + funName" will be the name of the setter.
- @warning The getter and setter are public virtual functions, you should rewrite them first.
- The variables and methods declared after CC_PROPERTY are all public.
- If you need protected or private, please declare.
- */
-#define CC_PROPERTY(varType, varName, funName)\
-protected: varType varName;\
-public: virtual varType get##funName(void);\
-public: virtual void set##funName(varType var);
-
-#define CC_PROPERTY_PASS_BY_REF(varType, varName, funName)\
-protected: varType varName;\
-public: virtual const varType& get##funName(void) const;\
-public: virtual void set##funName(const varType& var);
-
-/** CC_SYNTHESIZE_READONLY is used to declare a protected variable.
- We can use getter to read the variable.
- @param varType the type of variable.
- @param varName variable name.
- @param funName "get + funName" will be the name of the getter.
- @warning The getter is a public inline function.
- The variables and methods declared after CC_SYNTHESIZE_READONLY are all public.
- If you need protected or private, please declare.
- */
-#define CC_SYNTHESIZE_READONLY(varType, varName, funName)\
-protected: varType varName;\
-public: virtual varType get##funName(void) const { return varName; }
-
-#define CC_SYNTHESIZE_READONLY_PASS_BY_REF(varType, varName, funName)\
-protected: varType varName;\
-public: virtual const varType& get##funName(void) const { return varName; }
-
-/** CC_SYNTHESIZE is used to declare a protected variable.
- We can use getter to read the variable, and use the setter to change the variable.
- @param varType the type of variable.
- @param varName variable name.
- @param funName "get + funName" will be the name of the getter.
- "set + funName" will be the name of the setter.
- @warning The getter and setter are public inline functions.
- The variables and methods declared after CC_SYNTHESIZE are all public.
- If you need protected or private, please declare.
- */
-#define CC_SYNTHESIZE(varType, varName, funName)\
-protected: varType varName;\
-public: virtual varType get##funName(void) const { return varName; }\
-public: virtual void set##funName(varType var){ varName = var; }
-
-#define CC_SYNTHESIZE_PASS_BY_REF(varType, varName, funName)\
-protected: varType varName;\
-public: virtual const varType& get##funName(void) const { return varName; }\
-public: virtual void set##funName(const varType& var){ varName = var; }
-
-#define CC_SYNTHESIZE_RETAIN(varType, varName, funName) \
-private: varType varName; \
-public: virtual varType get##funName(void) const { return varName; } \
-public: virtual void set##funName(varType var) \
-{ \
- if (varName != var) \
- { \
- CC_SAFE_RETAIN(var); \
- CC_SAFE_RELEASE(varName); \
- varName = var; \
- } \
-}
-
-#define CC_SAFE_DELETE(p) do { delete (p); (p) = nullptr; } while(0)
-#define CC_SAFE_DELETE_ARRAY(p) do { if(p) { delete[] (p); (p) = nullptr; } } while(0)
-#define CC_SAFE_FREE(p) do { if(p) { free(p); (p) = nullptr; } } while(0)
-#define CC_SAFE_RELEASE(p) do { if(p) { (p)->release(); } } while(0)
-#define CC_SAFE_RELEASE_NULL(p) do { if(p) { (p)->release(); (p) = nullptr; } } while(0)
-#define CC_SAFE_RETAIN(p) do { if(p) { (p)->retain(); } } while(0)
-#define CC_BREAK_IF(cond) if(cond) break
-
-#define __CCLOGWITHFUNCTION(s, ...) \
- log("%s : %s",__FUNCTION__, String::createWithFormat(s, ##__VA_ARGS__)->getCString())
-
-// cocos2d debug
-#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
-#define CCLOG(...) do {} while (0)
-#define CCLOGINFO(...) do {} while (0)
-#define CCLOGERROR(...) do {} while (0)
-#define CCLOGWARN(...) do {} while (0)
-
-#elif COCOS2D_DEBUG == 1
-#define CCLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__)
-#define CCLOGERROR(format,...) cocos2d::log(format, ##__VA_ARGS__)
-#define CCLOGINFO(format,...) do {} while (0)
-#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
-
-#elif COCOS2D_DEBUG > 1
-#define CCLOG(format, ...) cocos2d::log(format, ##__VA_ARGS__)
-#define CCLOGERROR(format,...) cocos2d::log(format, ##__VA_ARGS__)
-#define CCLOGINFO(format,...) cocos2d::log(format, ##__VA_ARGS__)
-#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
-#endif // COCOS2D_DEBUG
-
-// Lua engine debug
-#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 || CC_LUA_ENGINE_DEBUG == 0
-#define LUALOG(...)
-#else
-#define LUALOG(format, ...) cocos2d::log(format, ##__VA_ARGS__)
-#endif // Lua engine debug
-
-#if defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUG__ == 4) && (__GNUC_MINOR__ >= 4))) \
- || (defined(__clang__) && (__clang_major__ >= 3))
-#define CC_DISABLE_COPY(Class) \
-private: \
- Class(const Class &) = delete; \
- Class &operator =(const Class &) = delete;
-#else
-#define CC_DISABLE_COPY(Class) \
-private: \
- Class(const Class &); \
- Class &operator =(const Class &);
-#endif
-
-/*
- * only certain compilers support __attribute__((deprecated))
- */
-#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
- #define CC_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
-#elif _MSC_VER >= 1400 //vs 2005 or higher
- #define CC_DEPRECATED_ATTRIBUTE __declspec(deprecated)
-#else
- #define CC_DEPRECATED_ATTRIBUTE
-#endif
-
-/*
- * only certain compiler support __attribute__((format))
- * formatPos - 1-based position of format string argument
- * argPos - 1-based position of first format-dependent argument
- */
-#if defined(__GNUC__) && (__GNUC__ >= 4)
-#define CC_FORMAT_PRINTF(formatPos, argPos) __attribute__((__format__(printf, formatPos, argPos)))
-#elif defined(__has_attribute)
- #if __has_attribute(format)
- #define CC_FORMAT_PRINTF(formatPos, argPos) __attribute__((__format__(printf, formatPos, argPos)))
- #endif // __has_attribute(format)
-#else
-#define CC_FORMAT_PRINTF(formatPos, argPos)
-#endif
-
-#if defined(_MSC_VER)
-#define CC_FORMAT_PRINTF_SIZE_T "%08lX"
-#else
-#define CC_FORMAT_PRINTF_SIZE_T "%08zX"
-#endif
-
-#ifdef __GNUC__
-#define CC_UNUSED __attribute__ ((unused))
-#else
-#define CC_UNUSED
-#endif
-
-//
-// CC_REQUIRES_NULL_TERMINATION
-//
-#if !defined(CC_REQUIRES_NULL_TERMINATION)
- #if defined(__APPLE_CC__) && (__APPLE_CC__ >= 5549)
- #define CC_REQUIRES_NULL_TERMINATION __attribute__((sentinel(0,1)))
- #elif defined(__GNUC__)
- #define CC_REQUIRES_NULL_TERMINATION __attribute__((sentinel))
- #else
- #define CC_REQUIRES_NULL_TERMINATION
- #endif
-#endif
-
-#endif // __CC_PLATFORM_MACROS_H__
diff --git a/cocos/platform/cocoa/CCAffineTransform.cpp b/cocos/platform/cocoa/CCAffineTransform.cpp
deleted file mode 100644
index 2e39f344cc..0000000000
--- a/cocos/platform/cocoa/CCAffineTransform.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-Copyright (c) 2010 cocos2d-x.org
-
-http://www.cocos2d-x.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-****************************************************************************/
-#include "CCAffineTransform.h"
-#include
-#include
-
-using namespace std;
-
-
-NS_CC_BEGIN
-
-AffineTransform __CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty)
-{
- AffineTransform t;
- t.a = a; t.b = b; t.c = c; t.d = d; t.tx = tx; t.ty = ty;
- return t;
-}
-
-Point __CCPointApplyAffineTransform(const Point& point, const AffineTransform& t)
-{
- Point p;
- p.x = (float)((double)t.a * point.x + (double)t.c * point.y + t.tx);
- p.y = (float)((double)t.b * point.x + (double)t.d * point.y + t.ty);
- return p;
-}
-
-Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t)
-{
- Size s;
- s.width = (float)((double)t.a * size.width + (double)t.c * size.height);
- s.height = (float)((double)t.b * size.width + (double)t.d * size.height);
- return s;
-}
-
-
-AffineTransform AffineTransformMakeIdentity()
-{
- return __CCAffineTransformMake(1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
-}
-
-extern const AffineTransform AffineTransformIdentity = AffineTransformMakeIdentity();
-const AffineTransform AffineTransform::IDENTITY = AffineTransformMakeIdentity();
-
-Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform)
-{
- float top = rect.getMinY();
- float left = rect.getMinX();
- float right = rect.getMaxX();
- float bottom = rect.getMaxY();
-
- Point topLeft = PointApplyAffineTransform(Point(left, top), anAffineTransform);
- Point topRight = PointApplyAffineTransform(Point(right, top), anAffineTransform);
- Point bottomLeft = PointApplyAffineTransform(Point(left, bottom), anAffineTransform);
- Point bottomRight = PointApplyAffineTransform(Point(right, bottom), anAffineTransform);
-
- float minX = min(min(topLeft.x, topRight.x), min(bottomLeft.x, bottomRight.x));
- float maxX = max(max(topLeft.x, topRight.x), max(bottomLeft.x, bottomRight.x));
- float minY = min(min(topLeft.y, topRight.y), min(bottomLeft.y, bottomRight.y));
- float maxY = max(max(topLeft.y, topRight.y), max(bottomLeft.y, bottomRight.y));
-
- return Rect(minX, minY, (maxX - minX), (maxY - minY));
-}
-
-AffineTransform AffineTransformTranslate(const AffineTransform& t, float tx, float ty)
-{
- return __CCAffineTransformMake(t.a, t.b, t.c, t.d, t.tx + t.a * tx + t.c * ty, t.ty + t.b * tx + t.d * ty);
-}
-
-AffineTransform AffineTransformScale(const AffineTransform& t, float sx, float sy)
-{
- return __CCAffineTransformMake(t.a * sx, t.b * sx, t.c * sy, t.d * sy, t.tx, t.ty);
-}
-
-AffineTransform AffineTransformRotate(const AffineTransform& t, float anAngle)
-{
- float sine = sinf(anAngle);
- float cosine = cosf(anAngle);
-
- return __CCAffineTransformMake( t.a * cosine + t.c * sine,
- t.b * cosine + t.d * sine,
- t.c * cosine - t.a * sine,
- t.d * cosine - t.b * sine,
- t.tx,
- t.ty);
-}
-
-/* Concatenate `t2' to `t1' and return the result:
- t' = t1 * t2 */
-AffineTransform AffineTransformConcat(const AffineTransform& t1, const AffineTransform& t2)
-{
- return __CCAffineTransformMake( t1.a * t2.a + t1.b * t2.c, t1.a * t2.b + t1.b * t2.d, //a,b
- t1.c * t2.a + t1.d * t2.c, t1.c * t2.b + t1.d * t2.d, //c,d
- t1.tx * t2.a + t1.ty * t2.c + t2.tx, //tx
- t1.tx * t2.b + t1.ty * t2.d + t2.ty); //ty
-}
-
-/* Return true if `t1' and `t2' are equal, false otherwise. */
-bool AffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2)
-{
- return (t1.a == t2.a && t1.b == t2.b && t1.c == t2.c && t1.d == t2.d && t1.tx == t2.tx && t1.ty == t2.ty);
-}
-
-AffineTransform AffineTransformInvert(const AffineTransform& t)
-{
- float determinant = 1 / (t.a * t.d - t.b * t.c);
-
- return __CCAffineTransformMake(determinant * t.d, -determinant * t.b, -determinant * t.c, determinant * t.a,
- determinant * (t.c * t.ty - t.d * t.tx), determinant * (t.b * t.tx - t.a * t.ty) );
-}
-
-NS_CC_END
diff --git a/cocos/platform/cocoa/CCAffineTransform.h b/cocos/platform/cocoa/CCAffineTransform.h
deleted file mode 100644
index 667b5d9b46..0000000000
--- a/cocos/platform/cocoa/CCAffineTransform.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-Copyright (c) 2010 cocos2d-x.org
-
-http://www.cocos2d-x.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-****************************************************************************/
-
-#ifndef __COCOA_CGAFFINETRANSFORM_H__
-#define __COCOA_CGAFFINETRANSFORM_H__
-
-#include "CCGeometry.h"
-#include "platform/CCPlatformMacros.h"
-
-NS_CC_BEGIN
-
-struct AffineTransform {
- float a, b, c, d;
- float tx, ty;
-
- static const AffineTransform IDENTITY;
-};
-
-CC_DLL AffineTransform __CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty);
-#define AffineTransformMake __CCAffineTransformMake
-
-CC_DLL Point __CCPointApplyAffineTransform(const Point& point, const AffineTransform& t);
-#define PointApplyAffineTransform __CCPointApplyAffineTransform
-
-CC_DLL Size __CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t);
-#define SizeApplyAffineTransform __CCSizeApplyAffineTransform
-
-CC_DLL AffineTransform AffineTransformMakeIdentity();
-CC_DLL Rect RectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform);
-
-CC_DLL AffineTransform AffineTransformTranslate(const AffineTransform& t, float tx, float ty);
-CC_DLL AffineTransform AffineTransformRotate(const AffineTransform& aTransform, float anAngle);
-CC_DLL AffineTransform AffineTransformScale(const AffineTransform& t, float sx, float sy);
-CC_DLL AffineTransform AffineTransformConcat(const AffineTransform& t1, const AffineTransform& t2);
-CC_DLL bool AffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2);
-CC_DLL AffineTransform AffineTransformInvert(const AffineTransform& t);
-
-extern CC_DLL const AffineTransform AffineTransformIdentity;
-
-NS_CC_END
-
-#endif // __COCOA_CGAFFINETRANSFORM_H__
diff --git a/cocos/platform/cocoa/CCArray.cpp b/cocos/platform/cocoa/CCArray.cpp
deleted file mode 100644
index 3a55d6050d..0000000000
--- a/cocos/platform/cocoa/CCArray.cpp
+++ /dev/null
@@ -1,754 +0,0 @@
-/****************************************************************************
-Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com
-Copyright (c) 2010 cocos2d-x.org
-
-http://www.cocos2d-x.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-****************************************************************************/
-
-#include "CCArray.h"
-#include "CCString.h"
-#include "platform/CCFileUtils.h"
-
-NS_CC_BEGIN
-
-
-#if CC_USE_ARRAY_VECTOR
-
-// ----------------------------------------------------------------------------------
-// std::vector implementation
-// ----------------------------------------------------------------------------------
-
-Array::Array()
-: data(NULL)
-{
- init();
-}
-
-Array* Array::create()
-{
- Array* array = new Array();
-
- if (array && array->initWithCapacity(7))
- {
- array->autorelease();
- }
- else
- {
- CC_SAFE_DELETE(array);
- }
-
- return array;
-}
-
-Array* Array::createWithObject(Object* object)
-{
- Array* array = new Array();
-
- if (array && array->initWithObject(object))
- {
- array->autorelease();
- }
- else
- {
- CC_SAFE_DELETE(array);
- }
-
- return array;
-}
-
-Array* Array::create(Object* object, ...)
-{
- va_list args;
- va_start(args,object);
-
- Array* array = create();
- if (array && object)
- {
- array->addObject(object);
- Object *i = va_arg(args, Object*);
- while (i)
- {
- array->addObject(i);
- i = va_arg(args, Object*);
- }
- }
- else
- {
- CC_SAFE_DELETE(array);
- }
-
- va_end(args);
-
- return array;
-}
-
-Array* Array::createWithArray(Array* otherArray)
-{
- return otherArray->clone();
-}
-
-Array* Array::createWithCapacity(int capacity)
-{
- CCASSERT(capacity>=0, "Invalid capacity");
-
- Array* array = new Array();
-
- if (array && array->initWithCapacity(capacity))
- {
- array->autorelease();
- }
- else
- {
- CC_SAFE_DELETE(array);
- }
-
- return array;
-}
-
-Array* Array::createWithContentsOfFile(const char* fileName)
-{
- Array* ret = Array::createWithContentsOfFileThreadSafe(fileName);
- if (ret != nullptr)
- {
- ret->autorelease();
- }
- return ret;
-}
-
-Array* Array::createWithContentsOfFileThreadSafe(const char* fileName)
-{
- return FileUtils::getInstance()->createArrayWithContentsOfFile(fileName);
-}
-
-bool Array::init()
-{
- return initWithCapacity(7);
-}
-
-bool Array::initWithObject(Object* object)
-{
- bool ret = initWithCapacity(7);
- if (ret)
- {
- addObject(object);
- }
- return ret;
-}
-
-/** Initializes an array with some objects */
-bool Array::initWithObjects(Object* object, ...)
-{
- bool ret = false;
- do
- {
- CC_BREAK_IF(object == nullptr);
-
- va_list args;
- va_start(args, object);
-
- if (object)
- {
- this->addObject(object);
- Object* i = va_arg(args, Object*);
- while (i)
- {
- this->addObject(i);
- i = va_arg(args, Object*);
- }
- ret = true;
- }
- va_end(args);
-
- } while (false);
-
- return ret;
-}
-
-bool Array::initWithCapacity(int capacity)
-{
- CCASSERT(capacity>=0, "Invalid capacity");
-
- data.reserve(capacity);
- return true;
-}
-
-bool Array::initWithArray(Array* otherArray)
-{
- data = otherArray->data;
- return true;
-}
-
-int Array::getIndexOfObject(Object* object) const
-{
- auto it = data.begin();
-
- for (int i = 0; it != data.end(); ++it, ++i)
- {
- if (it->get() == object)
- {
- return i;
- }
- }
-
- return -1;
-}
-
-Object* Array::getRandomObject()
-{
- if (data.size()==0)
- {
- return nullptr;
- }
-
- float r = CCRANDOM_0_1();
-
- if (r == 1) // to prevent from accessing data-arr[data->num], out of range.
- {
- r = 0;
- }
-
- r *= data.size();
-
- return data[r].get();
-}
-
-bool Array::containsObject(Object* object) const
-{
- int i = this->getIndexOfObject(object);
- return (i >=0);
-}
-
-bool Array::isEqualToArray(Array* otherArray)
-{
- for (int i = 0; i< this->count(); i++)
- {
- if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i)))
- {
- return false;
- }
- }
- return true;
-}
-
-void Array::addObject(Object* object)
-{
- data.push_back( RCPtr