The management method of cross-platform memory file and management system
Technical field
The present invention relates to embedded system, particularly relate to cross-platform memory file is imported/gone out in the embedded system management method and management system.
Background technology
Along with computer microprocessor and development of internet technology, the function of embedded platform is powerful gradually, and range of application also more and more widely.In embedded platform, owing to be subjected to the influence of embedded platform I/O operating efficiency or memory headroom size, Embedded Application is difference to some extent on the using method of data file, can select different modes of operation according to actual conditions usually.The file operation mode is carried out read operation by the I/O handling function of file to the data file, and this kind method has reduced engine to internal memory cost, but reading efficiency is lower.In the internal memory operation mode data file is loaded in the internal memory, engine conducts interviews to it by the memory address mode, and the reading efficiency of this kind method is higher, but higher to the space requirement of internal memory.Therefore, when the embedded platform memory headroom is little, but its external memory card read-write efficiency is very high, uses so and data file can be placed on the external memory card, operates on it with the I/O handling function; And when the I/O handling function work efficiency of embedded platform very low, but its memory headroom is very big, uses so and data file can be read earlier on the internal memory, operates on it with the mode of memory address.
The application programming interface of each embedded platform has conditions such as different titles, parameter, restriction, when product needed is transplanted between different platforms, just need to spend a large amount of being operated in and revise on the platform related function, be unfavorable for raising the efficiency and saving cost.In addition, the system vulnerability of introducing when revising also can increase the Products Development risk.
Summary of the invention
Technical matters to be solved by this invention provides a kind of management method and management system of cross-platform memory file, can realize the conversion of the different operating mode of cross-platform memory file, reduces development risk and cost of development.
In order to address the above problem, the invention discloses a kind of management method of cross-platform memory file, comprising:
Judge that it still is the internal memory operation mode that platform need adopt the file operation mode;
If it is empty needing file operation mode, engine maps file operation function, application module is introduced the file operation function entity by application programming interface engine is called, and the file operation function entity is write according to the characteristic of different platform;
If need the internal memory operation mode, engine maps file operation function is the memory address mode, and engine is by memory address mode reading of data, and application module calls engine.
Further, this method also is included in the file operation letter of the employing first macroblock mapped file mode of operation in the engine for empty.
Further, also to be included in and to adopt the file operation function of second macroblock mapping internal memory operation mode in the engine be the memory address mode to this method.
Further, this method comprises that also adopting first macro switch to control opens first macroblock.
Further, this method comprises that also adopting second macro switch to control opens second macroblock.
The invention also discloses a kind of management system of cross-platform memory file, comprising:
Engine, this engine comprises: first macroblock, the file operation function that is used for the mapped file mode of operation is for empty; Second macroblock, the file operation function that is used to shine upon the internal memory operation mode is the memory address mode;
Application module calls engine.
Further, this engine also comprises first macro switch, is used for control and opens first macroblock.
Further, this engine also comprises second macro switch, is used for control and opens second macroblock.
Further, this first macroblock and second macroblock all shine upon at least four file operation functions.
Further, this first macroblock and second macroblock all shine upon four file operation functions, and these four file operation functions are respectively jt_Fopen, jt_Fread, jt_Fseek, jt_Fclose.
Compared with prior art, the present invention has the following advantages:
In the management method of cross-platform memory file of the present invention and the management system when adopting the file operation mode, engine internal does not have the specific implementation of file operation mode, not needing to carry out entity when compiling connects, when therefore adopting first macroblock to come the representation file handling function, can compile and pass through.And at application module, the developer introduces the file operation function entity by application programming interface, just can realize using, and does not have extra transplanting work, and workload is less.Engine internal is provided with the random exchange that first macroblock and second macroblock can be realized mode of operation, when between different platform, transplanting, do not need extra development﹠ testing work, only need adjustment unlatching first macroblock or second macroblock to compile and get final product, therefore reduced the risk and the cost of exploitation.
Description of drawings
Fig. 1 is the structural representation of management system of the cross-platform memory file of the embodiment of the invention.
Fig. 2 is the schematic flow sheet of management method of the cross-platform memory file of the embodiment of the invention.
Embodiment
For above-mentioned purpose of the present invention, feature and advantage can be become apparent more, the present invention is further detailed explanation below in conjunction with the drawings and specific embodiments.
Please refer to Fig. 1, a kind of management system of cross-platform memory file is shown, comprise engine 10 and application module 30.Engine 10 comprises that first macroblock 11 and second macroblock, 13, the first macroblocks 11 are used for the file operation function of mapped file mode of operation, and second macroblock 13 is used to shine upon the internal memory operation mode.Engine 10 also comprises first macro switch of control unlatching first macroblock 11 and second macro switch that second macroblock 13 is opened in control.First macro switch is SMALL_FILE, and second macro switch is FIX_CONST.
Please refer to Fig. 2, a kind of management method of cross-platform memory file be shown, comprising:
S101, judge that it still is the internal memory operation mode that platform need adopt the file operation mode:
S103, if need the file operation mode, engine 10 mapped file handling functions are empty, and application module 30 is introduced the file operation function entity by application programming interface engine 10 is called, and the file operation function entity is write according to the characteristic of different platform;
If need the internal memory operation mode, engine 10 mapped file handling functions are the memory address mode, and engine 10 is by memory address mode reading of data, and application module 30 calls engine 10.
Be that example comes the management method of this cross-platform memory file is elaborated with platform A and platform B below:
The memory headroom of supposing platform A is less, but external memory card read-write efficiency is higher; The memory headroom of platform B is bigger, and external memory card read-write efficiency is lower.
When needs moved into platform A with data, the deviser can judge that according to the characteristic of platform A this moment should the select File mode of operation.It is empty opening four file operation functions of first macroblock 11, the first macroblocks, 11 mappings by first macro switch in the engine 10.When application module 30 need call engine 10, the deviser introduces the entity of four file operation functions by the application programming interface of application module 30, the introducing of file operation function entity can be passed through jt_Fopen, jt_Fread, jt_Fseek and jt_Fclose realize, four related functions, i.e. fopen that concrete implementation method then can normative reference C, fread, fseek and fclose.After introducing four file operation function entity, application module 30 just can be directly to calling engine 10, and write needed other codes of platform A, and need not other adaptation procedure according to the needs of self-characteristic, also need not original system is made amendment.
When needs moved into platform B with data, the deviser judged that according to the characteristic of platform B should select the internal memory operation mode this moment.Open second macroblock 13 by second macro switch in the engine 10, four file operation functions of second macroblock, 13 mappings are the memory address mode, and read related data by four file operation functions, this moment, application module 30 can directly call engine 10, by engine 10 related data is read in the internal memory, and write needed other codes of platform B according to the needs of self-characteristic, and need not other adaptation procedure, also need not original system is made amendment.
Same reason, in the time data migration need being arrived other platform, can adopt said method equally, need not the code in the engine 10 is made amendment, only need in application module 30, introduce corresponding entity as required or directly adopt the mode of memory address just can read related data, the adaptive work that has needed when having reduced cross-platform the transplanting, and reduced the risk of bringing because of the modification system.
In the management method and management system of cross-platform memory file of the present invention, control file opening mode of operation and internal memory operation mode respectively, can realize the transplanting of different platform datas by first macroblock 11 and second macroblock 13 that are provided with in the engine 10.Engine 10 does not need to carry out the entity link when compiling, therefore adopt first macroblock 11 to come the file operation function of representation file mode of operation or adopt second macroblock 13 to represent the file operation function of internal memory operation mode, when compiling, can pass through.Therefore, just can realize using as long as introduce function entity at application module 13.This kind method can realize the random conversion of mode of operation, when transplanting between different platform, does not need extra development﹠ testing work, only needs adjustment first macroblock and second macroblock to compile and gets final product, and has therefore reduced the risk and the cost of exploitation.In addition, replace mode of operation, when concrete platform application, just introduce function entity by macroblock, can write according to the characteristic of platform, need not the code in the engine is made amendment, avoid the system risk brought because of the modification system, and reduced the workload when transplanting.
More than to the management method and the management system of a kind of cross-platform memory file provided by the present invention, be described in detail, used specific case herein principle of the present invention and embodiment are set forth, the explanation of above embodiment just is used for helping to understand method of the present invention and core concept thereof; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, the part that all can change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.