summaryrefslogtreecommitdiff
path: root/src/maildir-select.cc
blob: 470dbbcbf03e3f9be161179d6c05a2020697dcec (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
43
/**
 *  @file maildir-select.cc
 *  @brief Implementation of the Maildir class.
 *  @author Andreas Aardal Hanssen
 *  @date Andreas Aardal Hanssen
 */

#include "maildir.h"

#include <fcntl.h>
#include <unistd.h>

using namespace Binc;

bool Binc::Maildir::selectMailbox(const std::string &name, const std::string &s_in)
{
  setName(name);

  if (selected) {
    closeMailbox();
    selected = false;
  }

  oldrecent = 0;
  oldexists = 0;

  mailboxchanged = false;

  setPath(s_in);

  switch (scan()) {
  case Success:
    break;
  case TemporaryError:
    if (scan() == Success) break;
    [[fallthrough]];
  case PermanentError:
    return false;
  }

  selected = true;
  return true;
}