summaryrefslogtreecommitdiff
path: root/imagelist-item.c
blob: 1c766f8aa436e26df868c7a073541ed972dbc5db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "imagelist-item.h"

cImageListItem::cImageListItem(const char *lname, const char *sname, eFileInfo type, const char *value, bool hide)
{
  LName = NULL;
  SName = NULL;
  Value = 0;
  SString = NULL;

  Edit(lname, sname, type, value, hide);
}

cImageListItem::~ cImageListItem(void)
{
  free(LName);
  free(SName);
  free(Value);
  free(SString);
}

void cImageListItem::Edit(const char *lname, const char *sname, eFileInfo type, const char *value, bool hide)
{
  free(LName);
  free(SName);
  free(Value);

  LName = lname ? strdup(lname) : NULL;
  SName = sname ? strdup(sname) : NULL;

  if(type == tFile && value && value[0] != '.') {
    if(0 >= asprintf(&Value, ".%s", value)) {
      return;
    }
  }
  else
    Value = value ? strdup(value) : NULL;

  fType = type;
  HideExt = hide;

  MakeSetupString();
}