{"id":295601,"date":"2019-12-17T16:21:00","date_gmt":"2019-12-17T16:21:00","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=295601"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=295601","title":{"rendered":"\u0417\u0430\u0442\u0438\u0440\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 Java"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/480256\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xd\/lt\/8v\/xdlt8v2q3xmo1axs_tx5m8ww_h8.jpeg\"><\/div>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u0441\u0442\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0444\u0430\u0439\u043b\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041d\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u0431\u044b \u0444\u0430\u0439\u043b\u044b \u0443\u0434\u0430\u043b\u044f\u043b\u0438\u0441\u044c \u043d\u0435 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0441\u0435\u0430\u043d\u0441\u0430, \u0440\u0430\u0431\u043e\u0442\u044b \u041f\u041a, \u0430 \u043f\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <br \/>  <a name=\"habracut\"><\/a><br \/>  \u0418 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u0442. \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Java \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 delete() \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 java.io.File \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430. <\/p>\n<pre><code class=\"java\">File file = new File(\"path\/to\/file\");  if (file.delete()) {   \tSystem.out.println(file.getName() + \" deleted\");    } else { \tSystem.out.println(file.getName() + \" not deleted\");    }  <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 delete() \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 java.io.File \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u043d\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u041e\u0421. \u0410 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u041e\u0421 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u044e\u0442 \u0444\u0430\u0439\u043b, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u0430\u043b\u044f\u044e\u0442 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f, \u0438 \u043f\u0430\u043c\u044f\u0442\u044c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u0430\u044f \u043f\u043e\u0434 \u0443\u0436\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430. \u041d\u043e \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439.<\/p>\n<p>  \u0418 \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u044b \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430, \u0442\u043e \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u0430\u043b\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Recuva\">Recuva<\/a>.<\/p>\n<p>  \u041d\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0447\u0442\u043e\u0431\u044b \u0444\u0430\u0439\u043b\u044b \u0431\u044b\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u0431\u0435\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0445 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c. \u041d\u0430\u0447\u0430\u0432 \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0431\u0435\u0437 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 (\u0437\u0430\u0442\u0438\u0440\u0430\u043d\u0438\u0435) \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u0418 \u043f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u041e\u0421. \u0418 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 API \u0438\u043b\u0438 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u043d\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0432 Ubuntu, \u0442\u043e \u044d\u0442\u0430 \u041e\u0421 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u043c\u0430\u043b\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u0443\u0442\u0438\u043b\u0438\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0442\u0438\u043b\u0438\u0442\u0430 secure-delete, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0431\u0435\u0437 \u0432\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b.<\/p>\n<pre><code class=\"bash\">$ srm -vz private\/* <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043b\u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442. \u041d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u041e\u0421, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u0443. <\/p>\n<p>  \u0427\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0443\u0439\u0442\u0438 \u043e\u0442 \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0443\u0442\u0438\u043b\u0438\u0442\u044b secure-delete, \u0442\u043e \u043e\u043d\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u043e\u0434 \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0430 \u042199 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0440\u0430\u0437\u043d\u0443\u044e \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u0443\u044e \u043c\u0430\u0433\u0438\u044e \u0438 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u043e-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439 API. \u041e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u043e \u0438 \u0435\u0449\u0435 \u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0443\u0442\u0438\u043b\u0438\u0442\u0430 secure-delete, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u044d\u0442\u0430\u043f\u044b.<\/p>\n<ul>\n<li>\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0444\u0430\u0439\u043b \u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0430\u0432.<\/li>\n<li> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430.<\/li>\n<li> \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u043a \u043d\u0443\u043b\u044c \u0431\u0430\u0439\u0442\u0430\u043c. <\/li>\n<li> \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0443\u0435\u0442 \u0444\u0430\u0439\u043b \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.<\/li>\n<li> \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0444\u0430\u0439\u043b.<\/li>\n<\/ul>\n<p>  secure-delete \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<ul>\n<li>Simple \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 1 \u043f\u0440\u043e\u0445\u043e\u0434\u043e\u043c 0x00 \u0431\u0430\u0439\u0442\u0430\u043c\u0438. <\/li>\n<li>DOE \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 3 \u043f\u0440\u043e\u0445\u043e\u0434\u0430\u043c\u0438 random, random, \u00abDoE\u00bb. <\/li>\n<li>RCMP \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 3 \u043f\u0440\u043e\u0445\u043e\u0434\u0430\u043c\u0438 0x00 ,0xFF, \u00abRCMP\u00bb.<\/li>\n<li>OPENBSD \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 3 \u043f\u0440\u043e\u0445\u043e\u0434\u0430\u043c\u0438 0xFF, 0x00, 0xFF \u0431\u0430\u0439\u0442\u0430\u043c\u0438.<\/li>\n<li>DOD \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 7 \u043f\u0440\u043e\u0445\u043e\u0434\u0430\u043c\u0438. <\/li>\n<li>Gutmann \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2014 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 35 \u043f\u0440\u043e\u0445\u043e\u0434\u0430\u043c\u0438.<\/li>\n<\/ul>\n<p>  \u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0434 \u0431\u044b\u043b \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u043e-\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043f\u043e\u0434 \u0440\u0430\u0437\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0421++, \u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u0430\u043f\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 secure-delete \u043f\u0440\u043e\u0434\u0435\u043b\u044b\u0432\u0430\u0435\u0442 \u0434\u043b\u044f \u0437\u0430\u0442\u0438\u0440\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 \u0444\u0430\u0439\u043b \u0438 \u0438\u043c\u0435\u0435\u0442 \u043b\u0438 \u043e\u043d \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c std::filesystem, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 C++17.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c boost::filesystem.<\/p>\n<pre><code class=\"cpp\">namespace fs = std::filesystem; \t if (!fs::exists(file)) { \tenv-&gt;ThrowNew(exception_class, \"File doesn't exist\"); } \t if (!fs::is_regular_file(file)) { \tenv-&gt;ThrowNew(exception_class, \"Path doesn't regular file or symlink\"); }  if (!eraser.check_permision(file, fs::status(file).permissions())) { \tenv-&gt;ThrowNew(exception_class, \"File hasn't enough permision (maybe not user)\"); } \t bool kl::erase_content::check_permision(const fs::path&amp; entry, fs::perms permision) { \ttry { \t\tfs::permissions(entry, fs::perms::owner_read | fs::perms::owner_write, \t\t\t\t\tfs::perm_options::add); \t\treturn true; \t} catch (fs::filesystem_error&amp; e) { \t\treturn false; \t} } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0442\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e, \u043a\u0430\u043a \u0432 secure-delete.<\/p>\n<pre><code class=\"cpp\">bool kl::erase_content::overwrite() { \tswitch (entry.get_mode()) { \tcase kl::overwrite_mode::SIMPLE_MODE: \t\tif (!overwrite_byte(1, 0x00)) { return false; } \t\tbreak; \tcase kl::overwrite_mode::DOE_MODE: \t\tif (!overwrite_random(1)) { return false; } \t\tif (!overwrite_random(2)) { return false; } \t        if (!overwrite_bytes(3, \"DoE\")) { return false; } \t\tbreak; \tcase kl::overwrite_mode::OPENBSD_MODE: \t\t\/* override OPENBSD_MODE method *\/ \t\tbreak; \tcase kl::overwrite_mode::RCMP_MODE: \t\t\/* override RCMP_MODE method *\/ \t\tbreak; \tcase kl::overwrite_mode::DOD_MODE: \t\t\/* override DOD_MODE method *\/ \t\tbreak; \tcase kl::overwrite_mode::GUTMAN_MODE: \t\t\/* override GUTMAN_MODE method *\/ \t\tbreak; \tdefault: \t\tstd::cerr &lt;&lt; \"overwrite mode doesn't choose\" &lt;&lt; std::endl; \t}  \treturn true; }\t <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0443\u0444\u0435\u0440 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u043e \u0431\u0443\u0444\u0435\u0440 \u0432 \u0444\u0430\u0439\u043b, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u043a\u043e\u043d\u0446\u0430.<\/p>\n<pre><code class=\"cpp\">bool kl::erase_content::overwrite_byte(const int pass, const uint8_t byte) { \tconst auto&amp; [file_name, file_size, buffer_size, mode] = entry;  \tthis-&gt;buffer = std::make_unique&lt;uint8_t[]&gt;(buffer_size); \tstd::memset(buffer.get(), byte, buffer_size);  \tthis-&gt;file = kl::fs_util::make_open_file(file_name, \"r+b\");  \tif (!overwrite_data(pass)) { \t\treturn false; \t}  \treturn true; } \t bool kl::erase_content::overwrite_data(const int pass) { \tconst auto&amp; [file_name, file_size, buffer_size, mode] = entry;  \tconst size_t count = file_size \/ buffer_size; \tconst size_t tail  = file_size % buffer_size; \tsize_t writted = 0;\t\t  \tif (fseek(file.get(), 0, SEEK_SET) != 0) { \t\tstd::cerr &lt;&lt; \"couldn't seek in file\" &lt;&lt; std::endl; \t\treturn false; \t}  \twritted = write_buffer(count, tail);  \tif (writted != file_size) { \t\tstd::cerr &lt;&lt; \"couldn't write buffer in file\" &lt;&lt; std::endl; \t\treturn false; \t}  \tfflush(file.get());  \tif (fseek(file.get(), 0, SEEK_SET) != 0) { \t\tstd::cerr &lt;&lt; \"couldn't seek in file\" &lt;&lt; std::endl; \t\treturn false; \t}  \tfile.reset();  \treturn true; } <\/code><\/pre>\n<p>  \u041f\u043e\u0442\u043e\u043c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 \u043a \u043d\u0443\u043b\u044c \u0431\u0430\u0439\u0442\u0430\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e std::filesystem::resize_file().<\/p>\n<pre><code class=\"cpp\">try { \tfs::resize_file(file, 0); } catch (fs::filesystem_error&amp; e) { \tenv-&gt;ThrowNew(exception_class, \"truncate file fail\"); } <\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e std::random() \u0438 std::filesystem::file::replace_filename().<\/p>\n<pre><code class=\"cpp\">std::string parent_path = file.parent_path(); std::string file_name   = file.filename(); fs::path copy_file = file;  file_name = random_text(file_name.size()); copy_file.replace_filename(fs::path(file_name));  try { \tfs::rename(file, copy_file); } catch (fs::filesystem_error&amp; e) { \tenv-&gt;ThrowNew(exception_class, \"can't rename file\"); }  return true; <\/code><\/pre>\n<p>  \u0418 \u043d\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u044e\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0444\u0430\u0439\u043b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e std::filesystem::remove().<\/p>\n<pre><code class=\"cpp\">try { \tfs::remove(copy_file); } catch (fs::filesystem_error&amp; e) { \tenv-&gt;ThrowNew(exception_class, \"can't remove file\"); } <\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 Java \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<pre><code class=\"java\">public class EraseFS { \tstatic { \t\tSystem.loadLibrary(\"jefl\");  \t} \t\t \tpublic static native boolean eraseFile(String path) throws EraseException; \tpublic static native boolean eraseFile(String path, OverwrideMode mode) throws EraseException; \t\t \tpublic static native boolean eraseFiles(String... paths) throws EraseException; \tpublic static native boolean eraseFiles(OverwrideMode mode, String... paths) throws EraseException; \t\t \tpublic static native boolean eraseDirectory(String path, boolean recursived) throws EraseException; \t\t \tpublic static native boolean eraseDirectory(String path, OverwrideMode mode, boolean recursived) throws EraseException; } <\/code><\/pre>\n<p>  \u041d\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0421++, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b. \u0418 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043d\u0435\u0442\u0443 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0439 \u043c\u0430\u043a\u0440\u043e\u0441\u043d\u043e\u0439 \u043c\u0430\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435 \u0442\u0430\u043a \u043b\u0435\u0433\u043a\u043e \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<p>  \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0421++17 \u0443\u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0432\u0441\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b: MVSC, Clang, GCC.<br \/>  \u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 github: <a href=\"https:\/\/github.com\/klappdev\/jefl\">code<\/a>.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/480256\/\"> https:\/\/habr.com\/ru\/post\/480256\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/480256\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xd\/lt\/8v\/xdlt8v2q3xmo1axs_tx5m8ww_h8.jpeg\"><\/div>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u0441\u0442\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0444\u0430\u0439\u043b\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0432\u043e\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041d\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u0431\u044b \u0444\u0430\u0439\u043b\u044b \u0443\u0434\u0430\u043b\u044f\u043b\u0438\u0441\u044c \u043d\u0435 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0441\u0435\u0430\u043d\u0441\u0430, \u0440\u0430\u0431\u043e\u0442\u044b \u041f\u041a, \u0430 \u043f\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-295601","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=295601"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295601\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=295601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=295601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=295601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}