Host library for controlling a WiConnect enabled Wi-Fi module.

Dependents:   wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more

types/File.h

Committer:
dan_ackme
Date:
2014-08-11
Revision:
1:6ec9998427ad
Parent:
0:ea85c4bb5e1f
Child:
11:ea484e1b7fc4

File content as of revision 1:6ec9998427ad:

/*
 * Copyright 2014, ACKme Networks
 * All Rights Reserved.
 *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks;
 * the contents of this file may not be disclosed to third parties, copied
 * or duplicated in any form, in whole or in part, without the prior
 * written permission of ACKme Networks.
 */

#pragma once


#include "Wiconnect.h"

namespace wiconnect
{


class File
{
public:
    File(int rxBufferLen = 0, void *rxBuffer = NULL);
    ~File();

    const char* getName() const;
    uint32_t getSize() const;
    FileType getType() const;
    FileFlags getFlags() const;
    uint32_t getVersion() const;
    const char* getVersionStr(char *buffer = NULL) const;

    WiconnectResult close();
    WiconnectResult read(void* buffer, uint16_t maxLength, uint16_t *bytesRead);
    WiconnectResult read(uint8_t **bufferPtr = NULL, uint16_t *bytesReadPtr = NULL);
    WiconnectResult getc(uint8_t *c);
    void clearRxBuffer();

    const File* getNext() const;
    const File* getPrevious() const;

protected:
    WiconnectResult openForRead(uint8_t handle, const char *filename);
    WiconnectResult initWithListing(const char *typeStr, const char *flagsStr, const char* sizeStr, const char *versionStr, const char *nameStr);

    uint8_t handle;
    bool readEnabled;
    char name[WICONNECT_MAX_FILENAME_SIZE];
    uint32_t size;
    FileType type;
    FileFlags flags;
    uint32_t version;
    Wiconnect *wiconnect;
    File *next;
    File *previous;

    Buffer rxBuffer;

    void* operator new(size_t size);
    void operator delete(void*);

    friend class FileInterface;
    friend class FileList;
};

}